Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to return the error level and error message from SQL file to windows batch file

3230967Jan 11 2017 — edited Jan 18 2017

Hi All,

I want to return the error level and error message from my sql file to windows batch file.

Please provide your suggestion on this.

Currently my sql file is  returning the error level as 1 in case of any error\s occurs.

IF /I "%ERRORLEVEL%" NEQ "1" (

@sqlplus /@xyzdb1 @e:\user\test\test_reports.sql

)

test_reports.sql

WHENEVER SQLERROR EXIT 1
SET TERMOUT OFF
SET LINESIZE 610
SET PAGES 0
SET ECHO OFF
SET TRIMSPOOL ON
SET FEEDBACK OFF
SET HEADING OFF
SET COLSEP ,
COLUMN DESCRIPTION FORMAT A50

col spoolname new_value spoolname

SELECT      'Mytest_report'
         || TO_CHAR (SYSDATE, 'yyyymmdd')
         || '.csv'
            spoolname
  FROM   DUAL;

spo '&spoolname';

SELECT  eno,ename,doj from
employee;

SPOOL OFF;

EXIT 0;

Thanks,

Ramya

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2017
Added on Jan 11 2017
4 comments
2,170 views