try something like this...have to be honest I dont do much PL/SQL programming, rather I maintain some of what we have that is in our ksh scripts. here is a sample.
Google,
Thanks for the prompt reply.
As I mentione before I'd like to get a value (like a value of a variable) from PL/SQL "SCRIPT" (not a function or procedure) back to the calling Unix script... I know how to do it when I call a stored function simply by return a value (return somevarable;)
Mind you I can not pass a value to a PL/SQL script (or I don't know how)
set isolation to dirty read;
select value from $PARAMTABLE
where parameter_key = 'SOD_FILE' and parameter_grp = 'extract_dates'
and gems_site = '$SITE'
!
dbaccess returns the result of the sql to stdout which is manipulated by sed and grep for the desired result and read into SOD_FILE.
(The dbaccess command could be back quoted and SOD_FILE set by assignment as you have done in your example).
Note here the use of environment variables (PARAMTABLE and SITE) embedded in the SQL. KSH will expand these variables and substitute their values into the sql before the dbaccess command is run.
Alternatively you could generate an sql file on the fly and clear it down afterwards. If you use the echo command, again the shell will expand environment variables.
I subscribe to a UNIX tip of the day from UGU and it just so happens that I received a tip on accessing our parameters from Oracle. Thought I would post it since it was differant from the solution provided...
OUT PARAMETER FROM ORACLE
Ever wanted to execute an
Oracle Procedure which contains
an out parameter, and use the
value returned from the out
parameter in the shell variable.
Try out this. The procedure
test1 adds two nos. and returns
output into the out parameter.
export ORACLE_HOME=< type in your Oracle Home Path >
export ORACLE_SID=< Mention the Oracle SID >
export PATH=$ORACLE_HOME:$ORACLE_HOME/bin:$PATH # This Path
is set to access the sqlplus executable
dummyvar=`sqlplus -s tcon4iqalib/tcon4iqalib <<end
set pagesize 0 feedback off ver off heading off echo off
serverout on
variable verr_mesg number
exec test1(4,5,:VERR_MESG)
print verr_mesg
exit;
end`
echo " Error is " $dummyvar
echo " Result is " $dummyvar
echo $dummyvar #end of shell script
This tip generously supported by: (edited)
FORUM RULE: NO EMAIL ADDRESSES (ANTISPAM RULE) - Neo