SQL*Plus spool only data and exclude errors

1.4k views Asked by At

I'm using .Bat file to execute an sql script, similar to this one

SET HEAD OFF
SET ECHO OFF
WHENEVER SQLERROR EXIT 1;

SPOOL D:\oracle\results.TXT

SELECT name FROM employee where employee_number = 123;

SPOOL OFF;
EXIT;

if the query runs I'll get the results without a problem, but if the database is down or something cause an oracle Error happens, I'll get an error in the text file ( which I don't want to), my question is:

  • Is there a way to spool the data if only the query runs without errors and to exclude if there is an error? or at least if there is an error.
  • Can I write a certain text in the results.txt file instead of oracle error?
0

There are 0 answers