Handling Exceptions From Java External Routines - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantageā„¢

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;

Result:

*** 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;

Result:

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