Precedence of Specific Condition Handlers | Teradata Vantage - Precedence of Specific 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™

A stored procedure can contain generic condition handlers and specific condition handlers which handle specific SQLSTATE codes or specific conditions defined by condition names). If a stored procedure contains both specific condition handlers and a generic condition handler to handle similar conditions, the specific condition handlers take precedence. The following rules apply to such situations.

  • When both SQLEXCEPTION and specific handlers for exception conditions are specified in a stored procedure.
    IF a raised exception … THEN this handler action executes …
    matches any of the SQLSTATE values specified for a handler the action defined for the specific condition handler.
    matches any of the condition names specified for a handler the action defined for the specific condition handler.
    does not match a specific SQLSTATE code or condition namespecified for any handler the action defined for the generic exception condition handler.
  • When both SQLWARNING and specific handlers for completion conditions are specified.
    IF a raised condition … THEN this handler action executes …
    matches any of the SQLSTATE values specified for a handler the action defined for the specific condition handler.
    matches any of the condition names specified for a handler the action defined for the specific condition handler.
    does not match a specific SQLSTATE code or condition name specified for any handler the action defined for the generic completion condition handler.
  • When both NOT FOUND and specific handlers for “no data found” completion conditions are specified.
    IF a “no data found” condition occurs and if the SQLSTATE value… THEN this handler action executes …
    matches any of the specific completion condition handlers the action defined for the specific completion condition handler.
    does not match any specific condition handler the action defined for the generic NOT FOUND condition handler.
  • The completion condition “no data found” has precedence over the other generic completion conditions. Only a generic NOT FOUND handler or a specific condition handler can handle the “no data found” completion condition.