Home » Infrastructure » Unix » Re: Host variables and Stored Procedures
Re: Host variables and Stored Procedures [message #96974] Fri, 05 October 2001 12:52
andrew again
Messages: 2577
Registered: March 2000
Senior Member
#!/bin/ksh
export ORACLE_SID=my_db
export ORACLE_HOME=/apps/oracle/app/oracle/product/8.0.4

RETVAL=`sqlplus -s maceya/pass <<EOF
set serveroutput on
WHENEVER SQLERROR EXIT 1
declare
x number;
begin
x := 999;
dbms_output.put_line('the_result_is '||x);
end;
/
exit;
EOF`

echo $RETVAL
X=`echo $RETVAL | awk '{print $2}'`
echo $X

sqlplus -s maceya/pass <<EOF | read RETVAL
set serveroutput on
WHENEVER SQLERROR EXIT 1
declare
x number;
begin
x := 999;
dbms_output.put_line('the_result_is '||x);
end;
/
exit;
EOF

echo $RETVAL

X=`echo $RETVAL | awk '{print $2}'`
echo $X

outout is:
---------
/home/maceya >t.ksh
the_result_is 999 PL/SQL procedure successfully completed.
999
the_result_is 999
999

----------------------------------------------------------------------
Previous Topic: Re: how to start Oracle thru unix shell
Next Topic: Re: Calling Oracle Procedures from Unix shell
Goto Forum:
  


Current Time: Tue Apr 16 09:44:50 CDT 2024