Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6784767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:02:21+00:00 2026-05-26T17:02:21+00:00

I use WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK; in my plsql scripts to use them

  • 0

I use “WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK;” in my plsql scripts to use them in shell scripts. This works fine:

echo exit | sqlplus user/pass@XE  @normal.sql && echo "boo"

Executes the script and prints “boo”
This works fine too:

echo exit | sqlplus user/pass@XE  @bad.sql && echo "boo"

“boo” is not printed.

However in case bad is:

WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK;

create or replace
PACKAGE TESTING
IS
function boo (co_id number) return varchar2;
END;
/

create or replace
PACKAGE BODY TESTING
is
end;

Which is obviously wrong – no error code is returned and “boo” is printed. How can I return plsqsl compilation error codes from sqlplus scripts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:02:22+00:00Added an answer on May 26, 2026 at 5:02 pm

    You will need to parse them from the output. Unix error codes are in the range 0 to 255, and theres all sorts of masks and signal stuff hidden in there. So you cannot record oracle error numbers in unix error codes.

    So basically you need to make your sql scripts include the show errors statement. But you do NOT want the WHENEVER statement in there because that will error before the errors are printed. e.g. bad.sql will be

    create or replace
    PACKAGE TESTING
    IS
    function boo (co_id number) return varchar2;
    END;
    /
    show errors
    
    create or replace
    PACKAGE BODY TESTING
    is
    end;
    /
    show errors
    

    Then your shell script should be something like:

    ERR_OUT="$( sqlplus rdbds/rdbds@XE  < bad.sql | egrep '^(ORA|PLS)-' )"
    if [ -n "$ERR_OUT" ]
    then
        echo "Errors in SQL:"
        echo "$ERR_OUT"
    else
        echo boo
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PHP 5, I use intval() whenever I get numbers as an input. This
Whenever we use an aggregate function in SQL ( MIN , MAX , AVG
Whenever I use pear, I get this strange warning message: $ pear list PHP
I am plannning to use whenever gem which among other things will also run
I know you should use POST whenever data will be modified on a public
Whenever I use the signal/slot editor dialog box, I have to choose from the
Whenever I use a macro in Visual Studio I get an annoying tip balloon
Whenever I use Html.ActionLink it always Html encodes my display string. For instance I
Whenever I use the rand function in C++: #include<iostream> #include<time.h> #include<stdlib.h> using namespace std;
Whenever I use WCF, I always try to make immutable classes that end up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.