Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: ksh scrip to include various sql commands and rownum

Re: ksh scrip to include various sql commands and rownum

From: Stephane CHAZELAS <this.address_at_is.invalid>
Date: Mon, 19 Jan 2004 12:27:44 +0100
Message-ID: <slrnc0nfpg.41.stephane.chazelas@spam.is.invalid>


2004-01-19, 11:44(+01), Robert:
[...]
> exit &num_of_rows
> EOD
> # echo $?
> num_of_rows=$?
> echo "Number of rows inserted = " $num_of_rows
[...][please don't top post]

You'd better not use the exit code to return values. If sqlplus fails with an error or was killed by some signal, that won't work.

Moreover, return codes are limites to the range {0-255} (in most Unices).

You'd better use a pipe:

value=$(sqlplus ... << EOF
...
select &num_of_rows;
EOF
)

or

returnedShellScript=$(sqlplus ... << EOF ...
select concat('value1=', &num_of_rows1,

              '\nvalue2=', &num_of_rows2); EOF
)
eval "$returnedShellScript"

-- 
Stéphane                      ["Stephane.Chazelas" at "free.fr"]
Received on Mon Jan 19 2004 - 05:27:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US