16.20 - Handling Exceptions From Java External Routines - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
English (United States)

The following rules apply when Teradata Database catches an exception from a Java external routine:

IF the class of the exception is... THEN...
not SQLException Teradata Database returns an SQLSTATE value of 38000. Here is an example:
*** Failure: Statement = 1  Info 0
      Code 7828: Unexpected Java Exception SQLSTATE 38000:
An java.lang.NullPointerException exception was thrown.

This typically occurs when the external routine fails to catch an exception.

SQLException If the SQLState field is five digits, where the first two digits are 38, then Teradata Database returns the SQLSTATE value. Here is an example:
SEL o_id, std_dev(o_amount);
FROM orders;

*** Failure 7825 in UDF/XSP/UDM UDFExample.std_dev:
SQLSTATE 38U01:  User Exception Text.

This is considered a properly returned error from a UDF.

If the SQLState field is out of range, then Teradata Database returns an SQLSTATE value of 39001. Here is an example:

SEL o_id, std_dev(o_amount);
FROM orders;

*** Failure 7827 Java SQL Exception SQLSTATE 39001: Invalid
SQL state (45100).