Precedence of Specific Condition Handlers | Teradata Vantage - Precedence of Specific Condition Handlers - Advanced SQL Engine - Teradata Database

SQL Stored Procedures and Embedded SQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
xqq1557098602407.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1148
lifecycle
previous
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.