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

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

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).