Elements of an SQL Stored Procedure - Advanced SQL Engine - Teradata Database

Database Introduction

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
qia1556235689628.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1091
lifecycle
previous
Product Category
Teradata Vantage™

An SQL stored procedure contains some or all of the following elements.

This element… Includes…
SQL control statements nested or non-nested compound statements.
Control declarations
  • Condition handlers in DECLARE HANDLER statements for completion and exception conditions. Conditional handlers can be:
    • CONTINUE or EXIT type.
    • Defined for a specific SQLSTATE code, the generic exception condition SQLEXCEPTION, or generic completion conditions NOT FOUND and SQLWARNING.
  • Cursor declarations in DECLARE CURSOR statements or in FOR iteration statements.

    Cursors can be either updatable or read only type.

    Cursors can also be result set cursors for returning the result of a SELECT statement executed in the stored procedure to the caller or client applications

  • Local variable declarations in DECLARE statements.
SQL transaction statements DDL, DCL, DML, and SELECT statements, including dynamic SQL statements, with a few exceptions.
LOCKING modifiers with all supported SQL statements except CALL.
Comments bracketed and simple comments.
Nested bracketed comments are not allowed.

For more information, see SQL Stored Procedures as SQL Applications.