Bteq equivalent of Sqlplus 'whenever sql error exit failure'

Database
N/A

Bteq equivalent of Sqlplus 'whenever sql error exit failure'

Hi -

Is there bteq equivalent of Oracle Sqlplus 'whenever sql error exit failure' ? I know I can code ".IF ERRORCODE <> 0 THEN .QUIT ERRORCODE", but I was just wondering if there is a statement that I can put at the begining and not worry about repeating this code after every SQL ststement in my code ??

Thanks

Sunil

Tags (1)
4 REPLIES

Re: Bteq equivalent of Sqlplus 'whenever sql error exit failure'

I don't believe so. You could create a single error handling section and then use the .IF ERRORCODE > 0 construct to jump to that section:

.LABEL ErrorHandler

/*
|| Perform whatever steps you need to here for log files etc.
*/

.EXIT ERRORCODE;

.LABEL BeginBTEQ

/*
|| Statement 1
*/

.IF ERRORCODE > 0 THEN GOTO ErrorHandler

It doesn't avoid having to repeat the error checking but it allows you to consolidate any processing to a central location in your BTEQ. 

Re: Bteq equivalent of Sqlplus 'whenever sql error exit failure'

sunilp:

Take a look at 'SET MAXERROR' in the bteq manuals.

HTH.

Cheers.

Carlos.

Re: Bteq equivalent of Sqlplus 'whenever sql error exit failure'

Good call Carlos! +1 for SET MAXERROR.

N/A

Re: Bteq equivalent of Sqlplus 'whenever sql error exit failure'

Thanks Carlos and Rob. My goal is to just quit from bteq when it encounters the first error and not process any other statements and ".SET MAXERROR 1" is doing it.  

Thanks

Sunil