Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Mon, 22 Feb 2011 @ 01:14:09 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Script returning wrong return code
From:   Baker, Andy

Setting errorlevel resets the severity which informs the return code set by BTEQ at termination and signalled back to the calling OS/script.

In effect, every BTEQ/Teradata errocode has a default errorlevel (the severity) - In the absence of any .set errorlevel commands the highest severity corresponding to any errorcode encountered during the script is the return code returned by BTEQ at completion. It is not the errorcode that is returned by BTWQ to calling script/os but this errorlevel (severity) unlkess one explicily peforms a QUIT n.

Typically it is 0,4,8,12,16.
(These values propbably originate from the standard convention of IBM MVS JCL step condition codes that still persists to this day and remembering that Teradata first had MVS as its Client/Host for BTEQ this probably explains their origibal setting/meaning form memory - 0 - OK, 4 - Warning, 8 condition completion (probably ok/maybe not), 12 - failure, 16-fatal)

The code/errorlevel assignments are listed in the BTEQ manual - if an errocode is not listed then the errorlevel is 8 . One can automattcially terminate BTEQ early by setting MAXERROR to say 8 but in the absence of MAXERROR BTEQ continues until end of script or an explicit .QUIT n.

So, in your script you have overrudden the default erorrlevel of 8 for errorcode 3807 to 0

This will have no effect except to ensure that your script ends with a return code of zero if no other errors are encountered. The script continues and then performs your .IF ERRORCODE <> 0 test. As the ERRORCODE is 3807 you have decided to QUIT and set the reurtn code to 20 explicitly.

What do you want to do?. Ignore the error and continue? If so, remove the .IF ERRORCODE test. If you want to stop immediately but with return code zero (don't think you want to do this but . . ) then change to .IF ERRORCODE <> 0 THEN QUIT 0.

Do you want to terminate immediatlely on any 3807? If so, set MAXERROR to 0 and .SET ERRORLEVEL 3807 SEVERITY 1 but this will complete with return code 1. Otherwise you will have remove the MAXERROR and test after each statement for the errorcode <> 0 and do a QUIT 0 if you still want to exit with return code 0.

Best to read BTEQ Manual and experiment as it easy to get the setting of these interactions behaving differently from intuition (or memory as above for that matter).


Andy Baker

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023