17.10 - 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
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

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

IF the class of the exception is... THEN...
not SQLException Vantage 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 Vantage 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 Vantage 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).