ERRORLEVEL - Basic Teradata Query

Basic Teradata Query Reference

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

ERRORLEVEL

Purpose  

Assigns severity levels to errors. Use the severity levels to determine a course of action based on the severity of the errors that BTEQ encounters.

If the ERRORLEVEL command has not been used; its value is ON by default.

Syntax  

where:

 

Syntax Element

Description

errno

A specific error number

n

The assigned severity level, where n = 2, 4, 8, or 12.

ON or OFF

Enable or disable the error level function.

UNKNOWN

Designation of other BTEQ error codes not defined by default mapping or by the user.

Usage Notes  

It is common practice to use a BTEQ script to query the status of the last Teradata SQL statement and obtain information such as the number of rows involved, and any error code that might have been returned by Teradata Database. The ERRORLEVEL command can extend that functionality by assigning a severity level to each Teradata SQL error code.

Also, use the ERRORLEVEL command to assign severity levels to the return codes that BTEQ returns to the operating system when a job completes. This way, ambiguous system-assigned error numbers can be correlated to meaningful levels of error severity for alerting users. (For more information on using return codes in this manner, see “Handling Errors” on page 88.

The ERRORLEVEL command includes one or more error items. Each error item consists of: either the word UNKNOWN, a single error number, or a parenthetical list of error numbers, followed by the word SEVERITY, followed by an integer value. The integer value is the new error level value for the listed error numbers.

(The error code of UNKNOWN accommodates any other BTEQ error codes that are not defined.)

For Mainframe BTEQ, in addition to the ON and OFF ERRORLEVEL command options, the BTEQ error level function can be enabled or disabled using the ERRORLEVEL environment variable in the JCL PARM in BTEQ STEP.

For example, to set ERRORLEVEL=OFF at startup, code the ERRORLEVEL environment variable in z/OS PARM as below:

   //BTEQ00   EXEC PGM=BTQMAIN,PARM='ENVAR(ERRORLEVEL=OFF)/'

The following example redefines the level of several errors and tests the result of a query using the IF...THEN... command.

   .SET ERRORLEVEL 2168 SEVERITY 4,
      (2173, 3342, 5262) SEVERITY 8
   .SET ERRORLEVEL UNKNOWN SEVERITY 16
   ...
   SELECT * FROM SOMEWHERE;
   .IF ERRORLEVEL >= 14 THEN .QUIT 17;
   ...