Home » Infrastructure » Unix » return code
return code [message #317167] Tue, 29 April 2008 15:13 Go to next message
navkrish
Messages: 189
Registered: May 2006
Location: NJ,USA
Senior Member

Hi,

$ORACLE_HOME/bin/sqlplus -S <<EOF >> $LOGDIR/$LOGFILE
$PASSWD
@/var/dba/common/bin/abc_tbl_refresh.sql
exit
EOF

if  [ $? -eq 0 ]
then
echo 'Running context index syn job.'
/var/dba/common/bin/sync_idx.ksh
fi

exit $?


Here exit is doen with return code '$?'. Will this be the return code of sql script 'abc_tbl_refresh.sql' fired or the if condition?

regards,
naveen
Re: return code [message #317172 is a reply to message #317167] Tue, 29 April 2008 15:54 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
I haven't verified, but it should from the last statement run (sync_idx.ksh). Working with SQLERRM etc in PL/SQL has the same issue.

Try
$ORACLE_HOME/bin/sqlplus -S <<EOF >> $LOGDIR/$LOGFILE
$PASSWD
WHENEVER SQLERROR EXIT 1 ROLLBACK
@/var/dba/common/bin/abc_tbl_refresh.sql
exit 0
EOF
RV=$?

# now test $RV...
Re: return code [message #317173 is a reply to message #317167] Tue, 29 April 2008 15:57 Go to previous message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
> Will this be the return code of sql script 'abc_tbl_refresh.sql' fired or the if condition?

No, issuing SQL*Plus EXIT command without any parameter returns success.

What do you mean with "return code of sql script"? I am afraid SQL script does not have something like that. It may end with error though.

You have two options though:
- issue WHENEVER OSERROR 1, WHENEVER SQLERROR 1 in the beginning of the SQL*Plus session; raise exception when you do not want to return zero (you have only two possible values for all SQL/OS errors)
-declare a SQL*Plus bind variable, assign it desired value and return it from SQL*Plus

In both cases, consult SQL*Plus User's Guide and Reference.
Previous Topic: Relationship Oracle with Unix?
Next Topic: Slow tablespace creation on HP-UX
Goto Forum:
  


Current Time: Sun Dec 04 00:05:53 CST 2016

Total time taken to generate the page: 0.05147 seconds