Returning SQLSTATE Values - Teradata Vantage - Analytics Database

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2026-03-06
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantage™

A Java UDF can throw a java.lang.SQLException with an exception number and message that are returned and used to set the SQLSTATE value and error message.

Valid values for the SQLState field of the SQLException are in the range 38U00 to 38U99.

Here is an example:

public class UDFExample {

   public static Integer fact( Integer x )
   throws SQLException
   {
      int factresult = 0;
      if (x != null)
         factresult = 1;
      else
         throw new SQLException("Input value not valid", "38U01");
      ...
      return new Integer(factresult);
   }

   ...

}

SQLException is the only valid exception that Java external routines can throw.