Skip to Main Content

Oracle Database Discussions

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 trap SP2- errors? script fails but sqlplus returns success

558772May 24 2008 — edited May 24 2008
i have the following script

SET NEWPAGE NONE;
SET SPACE 0;
SET LINESIZE 32767;
SET PAGESIZE 0;
SET ECHO OFF;
SET FEEDBACK OFF;
SET VERIFY OFF;
SET HEADING OFF;
SET MARKUP HTML OFF;
SET TERMOUT OFF;
SET TRIMOUT ON;
SET TRIMSPOOL ON;
SET TAB OFF;
SET LONG 4000;
SET LONGCHUNKSIZE 4000;
SET WRAP OFF;
ALTER SESSION SET NLS_DATE_FORMAT='dd/MM/yyyy';
WHENEVER SQLERROR EXIT -1;
WHENEVER OSERROR EXIT -2;

SPOOL C:\DUMP\&1\sad_spy.txt
SELECT sad.DEC_REF_YER||chr(9)||
sad.IDE_CUO_COD||chr(9)||
sad.DEC_COD||chr(9)||
sad.DEC_REF_NBR||chr(9)||
(CASE
WHEN track.STATUS='Cancelled' THEN
DECODE(sad.IDE_AST_NBR,NULL,DECODE(sad.IDE_REG_NBR,NULL,'Cancelled','8'),'13')
WHEN track.STATUS='Activated' THEN '11'
WHEN track.STATUS='Deleted THEN '25'
ELSE '1' --Stored
END)||chr(9)||
usr.USERNAME||chr(9)||
TO_CHAR(track.OP_DATE_TIME,'yyyy/MM/dd')||chr(9)||
TO_CHAR(track.OP_DATE_TIME,'hh24:mi:ss')||chr(9)||
sad.PTY_COL_IND||chr(9)||
sad.EXA_SEC||chr(9)||
sad.EXA_EXA||chr(9)||
sad.EXA_CEX||chr(9)||
DECODE(track.DOC_VER,1,'0','1')||chr(9)||
'1'||chr(9)||
sad.IDE_PST_NBR||chr(9)||
track.DOC_VER
FROM
GEN_TAB sad,
TRACK_TAB track,
IED_TRACK_TAB ied,
ADMUSR.USER_ACCOUNT usr
WHERE sad.INSTANCEID=ied.INSTANCE_ID
AND ied.IED_ID=track.IED_ID
AND track.END_USER=usr.USERID

attemtping to run that script, the return code is 0 all the time but in the spooled file, i get

SP2-0042: unknown command "FROM" - rest of line ignored.
SP2-0734: unknown command beginning "GEN_TAB..." - rest of line ignored.
SP2-0734: unknown command beginning "TRACK_TAB..." - rest of line ignored.
SP2-0734: unknown command beginning "IED_TRACK_T..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "ADMUSR.USER..." - rest of line ignored.
SP2-0734: unknown command beginning "WHERE sa..." - rest of line ignored.
SP2-0734: unknown command beginning "AND ied..." - rest of line ignored.
SP2-0734: unknown command beginning "AND tra..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "AND tra..." - rest of line ignored.
SP2-0734: unknown command beginning "AND sad..." - rest of line ignored.


if i inspect ERRORLEVEL, i get 0 which means success. how come?
I should note that it works for ORA- errors and OS errors as well, i get the appropriate return value ! How am i supposed to know if my script worked or not when an SP2- error is thrown sqlplus does not report it, so how am i supposed to trap these SP2- error ?

running 10g R2 10.2.0.2 on windows Xp,
client is SQL*Plus: Release 11.1.0.6.0

Message was edited by:
u_steven
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2008
Added on May 24 2008
7 comments
6,944 views