10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Programming
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
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. UNIX for Dummies Questions & Answers
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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
DBLINK(3) PostgreSQL 9.2.7 Documentation DBLINK(3)
NAME
dblink - executes a query in a remote database
SYNOPSIS
dblink(text connname, text sql [, bool fail_on_error]) returns setof record
dblink(text connstr, text sql [, bool fail_on_error]) returns setof record
dblink(text sql [, bool fail_on_error]) returns setof record
DESCRIPTION
dblink executes a query (usually a SELECT, but it can be any SQL statement that returns rows) in a remote database.
When two text arguments are given, the first one is first looked up as a persistent connection's name; if found, the command is executed on
that connection. If not found, the first argument is treated as a connection info string as for dblink_connect, and the indicated
connection is made just for the duration of this command.
ARGUMENTS
conname
Name of the connection to use; omit this parameter to use the unnamed connection.
connstr
A connection info string, as previously described for dblink_connect.
sql
The SQL query that you wish to execute in the remote database, for example select * from foo.
fail_on_error
If true (the default when omitted) then an error thrown on the remote side of the connection causes an error to also be thrown locally.
If false, the remote error is locally reported as a NOTICE, and the function returns no rows.
RETURN VALUE
The function returns the row(s) produced by the query. Since dblink can be used with any query, it is declared to return record, rather
than specifying any particular set of columns. This means that you must specify the expected set of columns in the calling query --
otherwise PostgreSQL would not know what to expect. Here is an example:
SELECT *
FROM dblink('dbname=mydb', 'select proname, prosrc from pg_proc')
AS t1(proname name, prosrc text)
WHERE proname LIKE 'bytea%';
The "alias" part of the FROM clause must specify the column names and types that the function will return. (Specifying column names in an
alias is actually standard SQL syntax, but specifying column types is a PostgreSQL extension.) This allows the system to understand what *
should expand to, and what proname in the WHERE clause refers to, in advance of trying to execute the function. At run time, an error will
be thrown if the actual query result from the remote database does not have the same number of columns shown in the FROM clause. The column
names need not match, however, and dblink does not insist on exact type matches either. It will succeed so long as the returned data
strings are valid input for the column type declared in the FROM clause.
NOTES
A convenient way to use dblink with predetermined queries is to create a view. This allows the column type information to be buried in the
view, instead of having to spell it out in every query. For example,
CREATE VIEW myremote_pg_proc AS
SELECT *
FROM dblink('dbname=postgres', 'select proname, prosrc from pg_proc')
AS t1(proname name, prosrc text);
SELECT * FROM myremote_pg_proc WHERE proname LIKE 'bytea%';
EXAMPLES
SELECT * FROM dblink('dbname=postgres', 'select proname, prosrc from pg_proc')
AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc
------------+------------
byteacat | byteacat
byteaeq | byteaeq
bytealt | bytealt
byteale | byteale
byteagt | byteagt
byteage | byteage
byteane | byteane
byteacmp | byteacmp
bytealike | bytealike
byteanlike | byteanlike
byteain | byteain
byteaout | byteaout
(12 rows)
SELECT dblink_connect('dbname=postgres');
dblink_connect
----------------
OK
(1 row)
SELECT * FROM dblink('select proname, prosrc from pg_proc')
AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc
------------+------------
byteacat | byteacat
byteaeq | byteaeq
bytealt | bytealt
byteale | byteale
byteagt | byteagt
byteage | byteage
byteane | byteane
byteacmp | byteacmp
bytealike | bytealike
byteanlike | byteanlike
byteain | byteain
byteaout | byteaout
(12 rows)
SELECT dblink_connect('myconn', 'dbname=regression');
dblink_connect
----------------
OK
(1 row)
SELECT * FROM dblink('myconn', 'select proname, prosrc from pg_proc')
AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc
------------+------------
bytearecv | bytearecv
byteasend | byteasend
byteale | byteale
byteagt | byteagt
byteage | byteage
byteane | byteane
byteacmp | byteacmp
bytealike | bytealike
byteanlike | byteanlike
byteacat | byteacat
byteaeq | byteaeq
bytealt | bytealt
byteain | byteain
byteaout | byteaout
(14 rows)
PostgreSQL 9.2.7 2014-02-17 DBLINK(3)