HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Error Handling - Oracle SQL
Operating System - HP-UX
1831355
Members
3165
Online
110024
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2006 05:01 AM
07-28-2006 05:01 AM
Error Handling - Oracle SQL
Hi,
One of my shell script calls the following SQL.
echo $ORA_PW|sqlplus $ORA_ID@$DB @$SQL/inventory.sql 1>$LOG/inventory.log 2>$STD_ERR/inventory.err
I usually read the log file to see if there are any SQL errors and abend the job
(autosys job which calls my shell script) if there are any.
Question:
I want to know what are the other possible ways to handle the SQL errors within shell script without reading log files ?
1) After calling the SQL , in the next line i tried putting " if [ $? != 0 ] " it always returning 0 irrespective of success/failure of above SQL.
Any HELP!!!!!
One of my shell script calls the following SQL.
echo $ORA_PW|sqlplus $ORA_ID@$DB @$SQL/inventory.sql 1>$LOG/inventory.log 2>$STD_ERR/inventory.err
I usually read the log file to see if there are any SQL errors and abend the job
(autosys job which calls my shell script) if there are any.
Question:
I want to know what are the other possible ways to handle the SQL errors within shell script without reading log files ?
1) After calling the SQL , in the next line i tried putting " if [ $? != 0 ] " it always returning 0 irrespective of success/failure of above SQL.
Any HELP!!!!!
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2006 05:18 AM
07-28-2006 05:18 AM
Re: Error Handling - Oracle SQL
If you add the following to the beginning of your SQL script it should give you a non-zero return code on errors:
whenever sqlerror exit sql.sqlcode
Just note that it will exit sqlplus at the point of the error and not continue on.
whenever sqlerror exit sql.sqlcode
Just note that it will exit sqlplus at the point of the error and not continue on.
Decay is inherent in all compounded things. Strive on with diligence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2006 06:06 AM
07-28-2006 06:06 AM
Re: Error Handling - Oracle SQL
Hi,
Here's the syntax for the "WHENEVER SQLERROR" command:
http://lbd.epfl.ch/f/teaching/courses/oracle8i/server.815/a66736/ch8b26.htm
Note that "WHENEVER SQLERROR" works for most, but not all Oracle errors.
PCS
Here's the syntax for the "WHENEVER SQLERROR" command:
http://lbd.epfl.ch/f/teaching/courses/oracle8i/server.815/a66736/ch8b26.htm
Note that "WHENEVER SQLERROR" works for most, but not all Oracle errors.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2006 04:08 PM
07-28-2006 04:08 PM
Re: Error Handling - Oracle SQL
Add the following two lines to the very top of your $SQL/inventory.sql file:
whenever sqlerror exit sql.sqlcode rollback
whenever oserror exit oscode rollback
this prevents your session from making half-baked changes to the database since all the insert/update/delete statements will be rolled back in case of SQL and/or OS errors. No need to rollback selects as they are read only.
hope it helps!
whenever sqlerror exit sql.sqlcode rollback
whenever oserror exit oscode rollback
this prevents your session from making half-baked changes to the database since all the insert/update/delete statements will be rolled back in case of SQL and/or OS errors. No need to rollback selects as they are read only.
hope it helps!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP