DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: exit unix after sqlerror in procedure

  1. #1
    Join Date
    Sep 2004
    Posts
    24

    Angry exit unix after sqlerror in procedure

    Hi!

    Can anybody tell me, how it works to exit the UNIX Script after ANY SQLERROR has occured in my procedure??

    my unix script executes a few procedures,
    but how can i pass the error code to an unix variable and exit the unix script, if any oracle error occured?

    PHP Code:
    sqlplus -<<EOF1
    $usr
    /$pwd
    set serveroutput on feedback off verify off heading off 
    echo off
    whenever sqlerror 
    exit sql.sqlcode;
    exec cqt_proc_cdr_insert;
    exit;
    EOF1` 
    now - just for testing - i got the error (when i run the script with the -x command - ORA-01536 space quota exceeded -

    i got the errorcode on unix like 127,

    PHP Code:
    status=$? 
    I check the status, if there has any error occured within my procedure, it doesn't work.
    PHP Code:
    if [ $status -eq 0 ]; then
    exit
    echo 
    "error code"
    else 
    #go on within the unix script
    ..
    ..
    fi 


    Because if there is any "ORACLE error", the script must exit and display an error message.

    THANKS.

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool

    You cannot use SQL.SQLCODE as return code for Unix. Return codes for unix have to be <= 127.
    But try this:
    PHP Code:
    sqlplus -<<EOF1 
    $usr
    /$pwd 
    set serveroutput on feedback off verify off heading off 
    echo off 
    whenever sqlerror 
    exit 99
    exec cqt_proc_cdr_insert
    exit; 
    EOF1
    if [ $? -ne 0 ]
    then
       
    echo "!error" 
       
    exit 1
    fi
    #go on within the unix script 
    .. 
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width