Accepting out parameters from a pl/sql procedure [message #303274] |
Thu, 28 February 2008 10:57 |
shree_z
Messages: 75 Registered: February 2008
|
Member |
|
|
Hi all,
I want to accept 3 out parameters from the shell script.
Also I want to move a file from one directory to other depending on the returned values from the procedure.
I have a part of the shell script here.
[QUOTE]#!/bin/ksh
echo "=================================================="
echo "Beginning program " `date "+%m/%d/%y %H:%M:%S"` "\n"
echo "================================================="
datadir="/path/data";
archdir="/path/archive";
cd $datadir
ls -lrt A*.txt | awk '{print $9}' | while read fname
do
echo The file to be passed to importing program is $datadir/$fname
sqlplus -s apps/apps4you@GAMDEV << EOF
echo Connected
var request_id number(30);
var status varchar2(30);
var phase varchar2(30);
execute XX_Call_Import_Prgm('$fname','$datadir',:request_id,:status,:phase);
print request_id;
print phase;
print status;
exit
EOF
if [[$phase = "Completed"]] then
echo Import Successful
mv $fname $archdir
else
echo Import Not Successful
fi
done
echo "=================================================="
echo "Ending program " `date "+%m/%d/%y %H:%M:%S"` "\n"
echo "=================================================="[/QUOTE
]
Well here I want to put the condition
Quote: | if $phase ='Completed' and $status='Normal',
then
mv $fname $datadir
|
How do I put this condition and how can I use the variables declared in the sql section of this program in the script part?
Thanks in advance
|
|
|
|
|
Re: Accepting out parameters from a pl/sql procedure [message #303297 is a reply to message #303296] |
Thu, 28 February 2008 13:49 |
|
Michel Cadot
Messages: 68716 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
I have neither a database nor Unix by hand but try:
sqlplus <<EOF
connect ...
declare
var integer := 1;
begin
dbms_output.put_line('var='||var);
end;
/
exit;
EOF
You see the format of sqlplus output and how you can awk it to get what you want in a similar way you did with:
ls -lrt A*.txt | awk '{print $9}' | while read fname
Regards
Michel
[Updated on: Thu, 28 February 2008 13:50] Report message to a moderator
|
|
|
|