Solved

sqlplus doesn't give exit status

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Can anyone please tell me what does below Stored Procedure does? 4 33
Problem with duplicate records in Oracle query 16 40
Oracle dataguard 5 43
format dd/mm/yyyy parameter 16 30
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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…
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 how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

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