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

  • SEARCH
  • Home
  • 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 9200971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:53:33+00:00 2026-06-17T22:53:33+00:00

I’m running several sql scripts from bash. I want to see the summery of

  • 0

I’m running several sql scripts from bash. I want to see the summery of ORA-errors before adding commit. Something like this:

#!/bin/bash
S_DB2_CONNECTOR=""
echo "My statement"
SQL_STM=$( echo "UPDATE ..." | sqlplus login/pass@bd );
echo "Output:"
echo "$SQL_STM"
echo "searching for errors...."
echo $LOG_VAR | grep "ORA"
echo "before commit"
wait 1000
echo "COMMIT;" | sqlplus -s login/pass@bd;

But this doesn’t work, because sqlplus session is broken and !SURPRISE! sqlplus added auto commit after SQL_STM execution.

How to parse sqlplus output for ORA-/ST-errors before commit? Preferable in this terminal screen.

Maybe I do not need bash for parsing and sqlplus can do it for me? (So the session state will be preserved).

  • 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-06-17T22:53:35+00:00Added an answer on June 17, 2026 at 10:53 pm

    if you want to rollback / do some extra stuff in the case of an ORA code, then do it all in the SQL*PLUS session.

    i.e. run it as a script.

    set serverout on
    begin
      update...;
    
    exception
      when others -- others is a catch all, you can catch specific codes too
      then 
        rollback;
        dbms_output.put_line('Error!');
        dbms_output.put_line(sqlerrm); -- prints full error string
    end;
    /
    

    if you just want to signal to bash that a sql statement failed , you can just set as the first thing in sql*plus. whenever sqlerror exit sql.sqlcode (or whenever sqlerror (exit -1 etc) instead (see here). This would stop on the first error and return to your schell script with an appropriate return code.

    you can nest blocks eg:

    begin
      update ..;
      begin
        select id into v_id
          from tab
         where ...;
      exception
        when no_data_found
        then
          null;-- ignore that we didnt find a row
      end;
      -- if the select fails, we continue from here..
      delete...;
      begin
        savepoint mysave;
        your_proc(...);
      exception
       when others
       then
         rollback to mysave; -- of the call to your_proc fails, lets just toll that back alone
      end;
    
    end;
    

    etc.

    if you needed it to be interactive, you could do something like (dbms_alert)[http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_alert.htm#CHDCFHCI]:

    sqlplus /<<EOF | tee -a my.log
    set feedback on verify on serverout on 
    -- IE YOUR CODE HERE..
    select * from dual;
    begin
      null;
    end;
    /
    -- END OF YOUR CODE..
    -- now lets wait for an alert from another session:
    declare
      v_message  varchar2(32767);
      v_status   number;
    begin
      DBMS_ALERT.REGISTER('should_i_commit');
      DBMS_ALERT.WAITONE('should_i_commit', v_message, v_status); -- there is a timeout parameter you can set too
      if (v_message = 'Y')
      then
        dbms_output.put_line('I committed');
        commit;
      else
        dbms_output.put_line('I rolled back');
        rollback;
      end if;
    end;
    /
    EOF
    

    then in another session you can issue:

    SQL> exec dbms_alert.signal('should_i_commit', 'N');
    
    PL/SQL procedure successfully completed.
    
    SQL> commit;
    
    Commit complete.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I have a text area in my form which accepts all possible characters from

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.