Example: Returning the SQLSTATE Result Code Value - 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™

Consider the following external stored procedure C function:

void xsp_getregion( VARCHAR_LATIN *region,
                    char           sqlstate[6])
{
     ...
}

You can use the sqlstate argument to return the SQLSTATE result code value.

For example, if the value of the region argument is not a valid value, you can set the value of the sqlstate argument to return a data exception:

strcpy(sqlstate, "U0005");

In a BTEQ session, the exception condition appears in the following format, where dbname is the name of the database of the external stored procedure:

*** Failure 7504 in UDF/XSP  dbname.xsp_getregion: SQLSTATE U0005: