Sponsored Content
Top Forums Shell Programming and Scripting Request: How to Parse dynamic SQL query to pad extra columns to match the fixed number of columns Post 302930914 by DGPickett on Thursday 8th of January 2015 02:01:44 PM
Old 01-08-2015
In shell or some flavor of procedural SQL?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

2. Shell Programming and Scripting

Remove extra characters and sum the columns

I have data extracted like this: A=%123% B=%456% C=%789% A=%111% B=%222% C=%333% A=%777% B=%888% C=%999% Can someone please help me with a script to remove all the % signs and get the totals for A, B and C. So output will be: A=1368 B=666 C=2664 Thank you! (2 Replies)
Discussion started by: tatchel
2 Replies

3. Shell Programming and Scripting

splitting a huge line of file into multiple lines with fixed number of columns

Hi, I have a huge file with a single line. But I want to break that line into lines of with each line having five columns. My file is like this: code: "hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","you." I want it like this: code:... (1 Reply)
Discussion started by: rajsharma
1 Replies

4. UNIX for Dummies Questions & Answers

Add extra columns help

Hi Gurus, This below script adds a column extra to my flat file..But how can i add another column, Say if i just put mention an other column beside the first column..it does get generated but as one column only while IFS="" read r; do printf "dummy\t%s\n" "$r" done < xxx.txt > zzz.txt ... (9 Replies)
Discussion started by: saggiboy10
9 Replies

5. Shell Programming and Scripting

How to parse fixed-width columns which may include empty fields?

I am trying to selectively display several columns from a db2 query, which gives me a fixed-width output (partial output listed here): --------- -------------------------- ------------ ------ 000 0000000000198012 702 29 000 0000000000198013 ... (9 Replies)
Discussion started by: ahsh79
9 Replies

6. Shell Programming and Scripting

Match on columns and replace other columns

Hi Friends, I have the following input file cat input chr1 100 200 0.1 0.2 na 1 na nd chr1 105 200 0.1 0.2 1 1 na 98 chr1 110 290 nf 1 na nd na 1 chr2 130 150 12 3 na 1 na 1 chr3 450 600 nf nf na 10 na nd chr4 300 330 1 1 10 11 23 34 My requirement is 1. If $6 is na make $7 nd and... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. UNIX for Dummies Questions & Answers

Getting values of 2 columns from sql query in UNIX variables

Hi, I have connected to oracle database with sqlplus -s / <<EOF select ename, age from emp where empid=1234; EOF I want to save the values of ename and age in unix shell variables. Any pointers would be welcome.. Thanks in advance!!1 Cheers :):):):) (1 Reply)
Discussion started by: gonchusirsa
1 Replies

8. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

9. Programming

Query SQL get two values differents from the same columns

Hi, I have 2 different values in the same column and two different values in other column Query 1 ins name value 1 Test 12345 1 TestV1 12/10/2014 8 Test 85435 8 TestV1 11/11/2005 9 Test 42232 9 TestV1 19/10/2000 6 Test 54321... (6 Replies)
Discussion started by: faka
6 Replies

10. Shell Programming and Scripting

Adding columns from 2 files with variable number of columns

I have two files, file1 and file2 who have identical number of rows and columns. However, the script is supposed to be used for for different files and I cannot know the format in advance. Also, the number of columns changes within the file, some rows have more and some less columns (they are... (13 Replies)
Discussion started by: maya3
13 Replies
CREATE 
LANGUAGE(7) SQL Commands CREATE LANGUAGE(7) NAME
CREATE LANGUAGE - define a new procedural language SYNOPSIS
CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE langname HANDLER call_handler [ VALIDATOR valfunction ] DESCRIPTION
Using CREATE LANGUAGE, a PostgreSQL user can register a new procedural language with a PostgreSQL database. Subsequently, functions and trigger procedures can be defined in this new language. The user must have the PostgreSQL superuser privilege to register a new language. CREATE LANGUAGE effectively associates the language name with a call handler that is responsible for executing functions written in the language. Refer to the Programmer's Guide for more information about language call handlers. Note that procedural languages are local to individual databases. To make a language available in all databases by default, it should be installed into the template1 database. PARAMETERS
TRUSTED TRUSTED specifies that the call handler for the language is safe, that is, it does not offer an unprivileged user any functionality to bypass access restrictions. If this keyword is omitted when registering the language, only users with the PostgreSQL superuser privilege can use this language to create new functions. PROCEDURAL This is a noise word. langname The name of the new procedural language. The language name is case insensitive. A procedural language cannot override one of the built-in languages of PostgreSQL. For backward compatibility, the name may be enclosed by single quotes. HANDLER call_handler call_handler is the name of a previously registered function that will be called to execute the procedural language functions. The call handler for a procedural language must be written in a compiled language such as C with version 1 call convention and regis- tered with PostgreSQL as a function taking no arguments and returning the language_handler type, a placeholder type that is simply used to identify the function as a call handler. VALIDATOR valfunction valfunction is the name of a previously registered function that will be called when a new function in the language is created, to validate the new function. If no validator function is specified, then a new function will not be checked when it is created. The validator function must take one argument of type oid, which will be the OID of the to-be-created function, and will typically return void. A validator function would typically inspect the function body for syntactical correctness, but it can also look at other properties of the function, for example if the language cannot handle certain argument types. To signal an error, the validator function should use the elog() function. The return value of the function is ignored. DIAGNOSTICS
CREATE LANGUAGE This message is returned if the language is successfully created. ERROR: PL handler function funcname() doesn't exist This error is returned if the function funcname() is not found. NOTES
This command normally should not be executed directly by users. For the procedural languages supplied in the PostgreSQL distribution, the createlang(1) script should be used, which will also install the correct call handler. (createlang will call CREATE LANGUAGE internally.) In PostgreSQL versions before 7.3, it was necessary to declare handler functions as returning the placeholder type opaque, rather than lan- guage_handler. To support loading of old dump files, CREATE LANGUAGE will accept a function declared as returning opaque, but it will issue a NOTICE and change the function's declared return type to language_handler. Use the CREATE FUNCTION [create_function(7)] command to create a new function. Use DROP LANGUAGE [drop_language(7)], or better yet the droplang(1) script, to drop procedural languages. The system catalog pg_language records information about the currently installed procedural languages. Table "pg_language" Attribute | Type | Modifier ---------------+-----------+---------- lanname | name | lanispl | boolean | lanpltrusted | boolean | lanplcallfoid | oid | lanvalidator | oid | lanacl | aclitem[] | lanname | lanispl | lanpltrusted | lanplcallfoid | lanvalidator | lanacl -------------+---------+--------------+---------------+--------------+-------- internal | f | f | 0 | 2246 | c | f | f | 0 | 2247 | sql | f | t | 0 | 2248 | {=U} At present, with the exception of the permissions, the definition of a procedural language cannot be changed once it has been created. To be able to use a procedural language, a user must be granted the USAGE privilege. The createlang program automatically grants permis- sions to everyone if the language is known to be trusted. EXAMPLES
The following two commands executed in sequence will register a new procedural language and the associated call handler. CREATE FUNCTION plsample_call_handler () RETURNS language_handler AS '$libdir/plsample' LANGUAGE C; CREATE LANGUAGE plsample HANDLER plsample_call_handler; COMPATIBILITY
CREATE LANGUAGE is a PostgreSQL extension. HISTORY
The CREATE LANGUAGE command first appeared in PostgreSQL 6.3. SEE ALSO
createlang(1), CREATE FUNCTION [create_function(7)], droplang(1), DROP LANGUAGE [drop_language(l)], GRANT [grant(l)], REVOKE [revoke(l)], PostgreSQL Programmer's Guide SQL - Language Statements 2002-11-22 CREATE LANGUAGE(7)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy