Conditions and Condition Handlers | Teradata Vantage - Conditions and Condition Handlers - Teradata Vantage - Analytics Database

SQL Stored Procedures and Embedded SQL

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
2023-10-30
dita:mapPath
frc1628111662093.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
rjx1472253414573
lifecycle
latest
Product Category
Teradata Vantageā„¢

Condition handlers can be either SQLSTATE-based, generic, or associated with an user-defined condition.

SQLSTATE-based Condition Handlers

Execution of the SQL statements within a stored procedure may result in certain completion, exception, or warning conditions. These conditions are posted to the SQLSTATE status variable. You can declare a condition handler and associate it with one or more SQLSTATE values. The condition handler will execute its actions when the conditions represented by the specified SQLSTATE values occur during stored procedure execution.

Generic Conditions and Handlers

Generic conditions are represented by the keywords SQLEXCEPTION, SQLWARNING, or NOT FOUND. You can declare a condition handler and associate it with one or more generic conditions instead of specific SQLSTATE values. The condition handler will execute its actions when the specified generic conditions occur during stored procedure execution.

Condition Handlers for Condition Names

SQLSTATE is a 5-character string value. You can declare a mnemonic name and associate it with an SQLSTATE value to make it easier to remember what condition the SQLSTATE value represents. You can declare a condition handler and associate it with one or more condition names. The condition handler will execute its actions when the conditions identified by the condition names or the associated SQLSTATE values occur during stored procedure execution.

User-Defined Conditions and Handlers

You can define custom conditions by declaring a condition name without associating it with an SQLSTATE value. This is useful if the conditions represented by the SQLSTATE values do not meet your needs. You can declare a condition handler and associate it with one or more user-defined conditions. The condition handler will execute its actions when the user-defined conditions occur during stored procedure execution. You can use the SIGNAL statement to explicitly raise a user-defined condition.

Related Information