Testing Status Values - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
16.00
Published
November 2016
Language
English (United States)
Last Update
2018-04-25
dita:mapPath
hyz1479325149183.ditamap
dita:ditavalPath
Audience_PDF_include.ditaval
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

BTEQ tracks several status values that reflect the results of the most recently submitted Teradata SQL request and OS command. The values can be tested by using their associated keyword as part of conditions comprising an IF clause for an IF...THEN... command. Some of these values can also be used as arguments for other commands such as EXIT and EXITONDELAY. The values are:

Keyword Description
ACTIVITYCOUNT Indicates the number of rows affected by the last submitted request. For a data-returning request, this is the number of rows returned to BTEQ from the database. The value is 0 or a positive integer. The maximum value is 4,294,967,295 when connected to a 14.00(or earlier) database. Starting with the 14.10 database, the maximum increases to 18,446,744,073,709,551,615.
ERRORCODE Indicates the error code the database returned for the last submitted request. The value is 0 or a positive integer. A zero signifies the request completed without error. The set ERRORCODE value can change during the course of a REPEATED request. Only the value for the final repeated request is available to use.
ERRORLEVEL Indicates the highest severity level value encountered as mapped to each returned non-zero ERRORCODE value. The value is 0 or a positive integer. The maximum value is 2147483647. If all prior-returned ERRORCODE values have been 0, then ERRORLEVEL will also be 0. ERRORLEVEL does not reset to zero, as ERRORCODE will, when a submitted request does not result in an error. So if ERRORLEVEL needs to be tested against the last request submitted, ERRORCODE should be tested first, to see whether the request was successful or not. ERRORLEVEL is used as BTEQ's default EXIT RC value when no other value gets specified to be used.
WARNINGCODE Indicates the warning code the database returned for the last submitted request. The value is 0 or a positive integer. It can only be set to a value greater than 0 when its associated SQL request is successful. Otherwise, ERRORCODE is set. The set of unique DBS warning codes does not overlap with the set of unique DBS error codes. The ERRORONDBSWARNING command can be used to tell BTEQ to treat DBS warnings as though they were DBS errors. When ERRORONDBSWARNING is ON, WARNINGCODE as well as ERRORCODE gets set when the database returns a non-zero warning code. Additionally, ERRORLEVEL will get changed when the severity level associated with the code is higher in value than the pre-existing ERRORLEVEL value.
SYSTEMRETURNCODE Indicates the return value for the last processed OS or TSO command. This can be a negative or positive value. Interpretation of non-zero values is left up to the user. They do not necessarily mean the system call made actually failed. The keyword can be used in IF command conditions for all flavors of BTEQ. When its value changes, BTEQ's default EXIT RC is not altered. However, the keyword can be used as the EXIT command's argument - but only when using Windows BTEQ as DOS and PowerShell support negative value return codes. UNIX shells and z/OS JCL do not.