Solved

sqlplus doesn't give exit status

Posted on 1998-06-03
2
1,565 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 100 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now