![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error Message | chapmana | UNIX for Dummies Questions & Answers | 5 | 11-29-2006 07:41 AM |
| Error Message | RDM00 | UNIX for Dummies Questions & Answers | 2 | 10-06-2006 03:43 PM |
| Error message | ghuber | UNIX for Advanced & Expert Users | 1 | 11-14-2005 02:04 AM |
| error message vnc | Castelior | UNIX for Advanced & Expert Users | 3 | 10-21-2004 01:50 AM |
| error message | alisev | UNIX for Dummies Questions & Answers | 3 | 01-08-2002 01:01 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
SQL Error Message
Hi,
I have a script that will call a .sql file in unix. My question is, incase the .sql file encountered an error on execution (e.g. 'ORA-00942: table or view does not exist') is it possible to get that error back to the script that call the .sql file? Please give me an example. Thanks. |
| Forum Sponsor | ||
|
|
|
||||
|
This is not a full fledged script but will give you insight how to catch error.
Z=`sqlplus -s user/password@host <<eof set serveroutput on; declare v_message varchar2(1000); v_value number; begin select column into v_value from tablename where rownum<2; EXCEPTION WHEN OTHERS THEN v_message := SQLERRM; dbms_output.put_line(v_message); END; / EXIT; eof` v_message=`echo "$Z" | grep "ORA-"` echo $v_message |
|
||||
|
v_message=`echo "$Z" | grep "ORA-"`
echo $v_message Variable Z contains the ouput of sqlplus session.from that output we are searching for "ORA-" string,Which is prefix to oracle error.The lines found with ORA- String are kept in another variable v_message.Second line is printing that oracle error message. |
||||
| Google UNIX.COM |