15.00 - How SQL UDFs Handle SQL Result Codes - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1184-015K
Language
English (United States)

How SQL UDFs Handle SQL Result Codes

The ANSI SQL:2011 standard defines a return code variable named SQLSTATE to accept status code messages. All condition messages are returned to this variable in a standard ASCII character string format.

All SQLSTATE messages are 5 characters in length. The first 2 characters define the message class and the last 3 characters define the message subclass.

For example, consider the SQLSTATE return code ‘22021’. The class of this message, 22, indicates a data exception condition. Its subclass, 021, indicates that a character not in the defined repertoire was encountered.

Be aware that SQL warnings do not abort a request, while SQL exceptions do abort a request.

You should ensure that your UDFs always return valid SQLSTATE codes. Teradata Database does not map SQLSTATE values returned by SQL UDFs to their equivalent SQLCODE values. All SQLSTATE codes generated by SQL UDFs are explicitly mapped to Teradata Database messages as indicated by the following table:

 

IF the UDF returns this type of SQL return code …

THEN the system maps it to this error message …

AND displays it in this format …

Warning

7505

*** Warning 7505 in dbname.udfname: SQLSTATE 01Hxx:

Exception

7504

*** Error 7504 in dbname.udfname: SQLSTATE U0xxx:

See SQL Fundamentals for more information about SQL exception and warning codes.

See SQL Stored Procedures and Embedded SQL for more information about SQLSTATE and SQLCODE result codes.