The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error Message chapmana UNIX for Dummies Questions & Answers 5 11-29-2006 11:41 AM
Error Message RDM00 UNIX for Dummies Questions & Answers 2 10-06-2006 07:43 PM
Error message ghuber UNIX for Advanced & Expert Users 1 11-14-2005 06:04 AM
error message vnc Castelior UNIX for Advanced & Expert Users 3 10-21-2004 05:50 AM
error message alisev UNIX for Dummies Questions & Answers 3 01-08-2002 05:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2006
kakashi_jet kakashi_jet is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 12
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.
  #2 (permalink)  
Old 07-12-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
If you want that the execution of your script ends with an error status at the first error encountered, add the following code to your SQL script :

Code:
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR  EXIT FAILURE
Jean-Pierre.
  #3 (permalink)  
Old 07-12-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
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
  #4 (permalink)  
Old 07-12-2006
kakashi_jet kakashi_jet is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 12
Thanks for the reply.

What this code do?

v_message=`echo "$Z" | grep "ORA-"`
echo $v_message

Is it possible to assign value to a unix environment variable in .sql file?

Last edited by kakashi_jet; 07-12-2006 at 08:24 AM..
  #5 (permalink)  
Old 07-12-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0