|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parsing Oracle errors in script
Hi everyone.
I have a very simple script that uses oracle's 'imp' command to import data into a database. Once the process is finished, it emails me using mailx. Occasionally, it fails. I would like to be able to know when it fails and send a different email in case of failure. I know how to capture Oracle failures in PL/SQL, but not in unix. Can anyone help? Here is a snippet of code: (As i mentioned, it's very simple) ************** imp username/pass@db buffer=......TABLES=TABLENAME mailx -s "table imp" Joe <<+++ table imported. +++ *************** Thanks for your help! |
|
#2
|
|||
|
|||
|
At a guess the command will exit with a different value if it fails. In traditional Unix programs a zero exit value means that everything went ok. I find Oracle's docs almost impossible to navigate so a quick look on OTN didn't tell me what the exit values for imp are when it fails but you would usually want to do something like:
Code:
RETVAL=0
imp username/pass@db buffer=......TABLES=TABLENAME
RETVAL=$?
if [ $RETVAL = 0 ] ; then
mailx -s "table imp" Joe <<+++
table imported.
+++
elif [ $RETVAL = 1 ] ; then
mailx -s "table imp" Bob<<+++
table import failed.
+++
fi
Now, having written this, please understand that I'm not the worlds expert on shell scripts but something like this should be close. Last edited by stdunbar : July 27th, 2005 at 02:24 PM. Reason: Fixed some wierdness on the OTN link |
|
#3
|
|||
|
|||
|
imp does in fact return ZERO on sucess and non-zero on failure (almost always 1).
Code:
if [ $RETVAL -eq 0 ] ; then
mailx -s "table imp" Joe <<+++
table imported.
+++
else
mailx -s "table imp" Bob<<+++
table import failed.
+++
fi
|
|
#4
|
|||
|
|||
|
Quote:
Ok - I see what you're doing - if the error code is something different, I'll try to find it. Thanks a lot for your help!! |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Parsing Oracle errors in script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|