[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

sqlplus doesn't give exit status

Posted on 1998-06-03
2
Medium Priority
?
1,677 Views
Last Modified: 2008-02-01
I am running a script that connects to sqlplus and executes a file using the sqlplus connect_string @somefile. This file may generate errors but when sqlplus quits, the $status variable is still 0. How can I get sqlplus to set an exit status to non-zero if an error is encountered or is sqlplus setting some other variable. I am running Oracle 7.3.3 on AIX 4.2.1.

Thanx
Angel
0
Comment
Question by:aleyva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
csomu earned 400 total points
ID: 1081806
Hi Aleyva,

Sqlplus has a command called "whenever sqlerror exit <Variable>"

this variable can be anything like sql.sqlcode or your own variable that you have defined.

An example will be

sqlplus>whenever sqlerror exit sql.sqlcode
sqlplus>select tttt from tab;

Now it will display
select tttt from tab
       *
ERROR at line 1:
ORA-00904: invalid column name


Disconnected from Oracle7 Server Release 7.3.3.4.0 - Production Release
With the parallel query option
PL/SQL Release 2.3.3.4.0 - Production

Now at the $ prompt if you say echo $? it will return you the error code.I got 136.

I think this is what you are looking for.

Bye
Somu
0
 

Author Comment

by:aleyva
ID: 1081807
I had seen this is a sqlplus quick reference card, and also saw it in some code, but never tried it. I wanted to have someone else say that this is the way to do it and you have done this for me. Thank you

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question