Returning SQLSTATE Values | Java External Stored Procedures | Teradata Vantage - Returning SQLSTATE Values - 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ā„¢

A Java external stored procedure can throw a java.lang.SQLException with an exception number and message that are returned to the database 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 region {

   public static void newRegion( Integer[] regionID )
   throws SQLException
   {
       if (regionID[0] != null)
          regionID[0] = regionID[0].intValue() + 1;
       else
          throw new SQLException("Region ID not valid", "38U01");
   }

   ...

}

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