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

Thread: return code

  1. #1
    Join Date
    Apr 2001
    Posts
    103

    return code

    Hello Gurus
    Oracle version 10g
    server Solaris
    Client XP
    I am executing a script sql from a bat file which is as follows

    sqlplus par/fra@test @c:\ora_scr\REFRESH_IRT.sql
    echo errorlevel

    and my sql file is

    SET SERVEROUTPUT ON
    set echo off
    set feedback off
    set heading off
    SET TERMOUT OFF
    set linesize 1000


    var rc number;

    WHENEVER SQLERROR EXIT :rc

    SPOOL C:\ora_scr\FPT_IRT_DROP_COPY.SQL

    exec :rc :=1;
    SELECT 'DROP TABLE COPY_'||TABLE_NAME|| ' ;'
    FROM USER_TABLES WHERE TABLE_NAME LIKE 'IRT%'
    LAND TABLE_NAME != 'IRT_SCHED';

    SPOOL OFF

    I am trying to get the return code from the sqlplus to msdos.
    But after the sql error my dos promt disappears completely and I am unable to see the return code
    Any body has a solution for this
    Thanks for your help
    Naeem

  2. #2
    Join Date
    Apr 2006
    Posts
    377
    Try to put %'s around errorlevel:

    Code:
    sqlplus par/fra@test @c:\ora_scr\REFRESH_IRT.sql
    echo %errorlevel%
    and place an exit at the end of your sql script:

    Code:
    SET SERVEROUTPUT ON
    set echo off
    set feedback off
    set heading off
    SET TERMOUT OFF
    set linesize 1000
    
    var rc number;
    
    WHENEVER SQLERROR EXIT :rc
    
    SPOOL C:\ora_scr\FPT_IRT_DROP_COPY.SQL
    
    exec :rc :=1;
    SELECT 'DROP TABLE COPY_'||TABLE_NAME|| ' ;'
    FROM USER_TABLES WHERE TABLE_NAME LIKE 'IRT%'
    LAND TABLE_NAME != 'IRT_SCHED';
    
    SPOOL OFF
    exit

  3. #3
    Join Date
    Apr 2001
    Posts
    103
    Thanks for your reply.
    Naeem

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