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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Batch file is not returning the correct error level

3230967Sep 30 2016 — edited Oct 3 2016

Hi All,

I have created a batch file in windows server to execute the procedure using sqlplus commands.
Please find the script below

@sqlplus usr/pwd@rdcdev @e:\sample\script\test.sql
ECHO %ERRORLEVEL%

in test.sql file, i have the written the below code.

spool test.lst

BEGIN
test_email_notiff;
END;
/
spool off;

When the ran the batch file, the procedure did not get executed successfully.Please find the below error in lst file

BEGIN
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TEST_EMAIL_NOTIFF", line 7
ORA-06512: at line 2

and it returns the error level as '0'

Error informtion...is

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

BEGIN
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TEST_EMAIL_NOTIFF", line 7
ORA-06512: at line 2

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

e:\sample\script>ECHO 0 
0

Completed at 09/30/2016 05:14 AM

I want the batch file returns the code '1' whenever error occurs. Currently it is returning error level '0'

Please share your suggesstions.

Thanks,
Ramya

This post has been answered by Dejan T. on Sep 30 2016
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 31 2016
Added on Sep 30 2016
12 comments
1,906 views