?
Solved

sqlplus doesn't give exit status

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

764 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