Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Return Exit value to a unix shell script
Marc Weinsock <MWeinstock_at_lds.com> wrote:
> Does anyone know how the get sqlplus to return a exit value to a shell
> script? When I run the following script my "exit val" statement does
> not work. Is there a fix for this one?
If I were you I would try next shell code:
#!/bin/sh
var=`echo "select 'Result of my func' result, my_func from dual;
exit" |
sqlplus $ORAUSER/$ORAPASS@$ORAHOST |
sed -n 's/^Result of my func//p' |
while read result
do
echo ${result}
done`
if [ $var != "1" ]
then
echo DO SOMETHING
fi
if [ $var != "2" ]
then
echo DO SOMETHING ELSE
fi
> #!/bin/sh
> sqlplus $ORAUSER/$ORAPASS@$ORAHOST << EOF
> VARIABLE val number;
> begin
> select my_func into :val from dual;
> //my_func will return 1 or 2
> end;
> /
> exit val
> EOF
> if [ $? != "1" ]
> then
> echo DO SOMETHING
> fi
> }
> if [ $? != "2" ]
> then
> echo DO SOMETHING ELSE
> fi
> }
> --
> ===============================================
> Marc Weinstock
> Logical design Solutions
> 55 Broadway - 21st Floor
> New York, New York 10006
> Phone: 800.221.5327 x2136
> Fax: 212-825-2245
> E-Mail: MWeinstock_at_lds.com
> Web: http://www.lds.com
-- ---------------------------- E-mail: fia_at_ins.dn.ua
![]() |
![]() |