Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Sqlplus and Unix : getting a non zero return code

Sqlplus and Unix : getting a non zero return code

From: Simon <stemp1ar_at_yahoo.com>
Date: 20 Aug 2001 21:23:14 -0700
Message-ID: <8fe904ce.0108202023.7f6441fb@posting.google.com>


I need to call in the experts. I would like to call sqlplus, pass sql as a parm, run the sql and if there is a non zero return code exit the script. The test script below does not seem to send the output to correct output files.

Any help would be great...TIA

check_error() {

        if [[ -a errfile ]]; then
                err_count=$(grep -c -e ^[^$] errfile)
        else
                err_count=0
        fi
        if (( err_count > 0 )); then
           echo "\nErrors have been encountered.  Please refer to
errfile"
        fi

}

    sqlplus -s > test.out 1>errfile 2>logfile <<EOF     username/pass
    whenever sqlerror exit failure
    set serveroutput on
    spool outfile
    select count(*) from table_name;
    spool off;
    exit;
    EOF     RC=$?
    if [[ $RC = 0 ]]; then

          echo "Inside zero rc=$RC"
    else

          echo "Inside non-zero RC=$RC"
          exit -1

    fi

    check_error Received on Mon Aug 20 2001 - 23:23:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US