?
Solved

sqlplus doesn't give exit status

Posted on 1998-06-03
2
Medium Priority
?
1,686 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

809 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