Testing Status Values - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

BTEQ retains three status values reflecting the results of the most recent Teradata SQL request. These are the values that can be tested with the IF clause of an IF...THEN... command:

 

Value

Definition

ERRORCODE

Indicates the completion code associated with the request.

ERRORLEVEL

Indicates the severity level associated with an error code.

ACTIVITYCOUNT

Indicates the number of rows affected by the request. For a request resulting in a selection of rows, this is the number of rows returned to BTEQ from the database.

Note: An ERRORCODE value of zero signifies a request that completed without errors.

Testing Example

For example, if a Teradata SQL SELECT request succeeded and returned the contents of 23 rows, the ERRORCODE value associated with the request would be zero, and the ACTIVITYCOUNT would be 23. The value of ERRORLEVEL depends upon whether the submitted request results in an error or not. Or, if a Teradata SQL DELETE request encountered no rows that met the specified delete criteria, but encountered no error conditions, all three values would be zero: there is no error condition, consequently no severity level, and no rows affected.

Note: The value of ERRORLEVEL does not reset to zero as is done for ERRORCODE when a submitted request does not result in an error. If the value of ERRORLEVEL needs to be tested against the last request submitted, ERRORCODE should be tested first, to see whether the request was successful or not.

For more information about error codes and severity levels, refer to “Handling Errors” on page 89. Table 2, Table 3, and Table 4 list the Teradata Database error messages that are assigned default severity levels (return codes) of 04, 08, and 012, respectively. For a complete list of all Teradata Database error codes, refer to Messages.