15.00 - 15.10 - Elements of an SQL Stored Procedure - Teradata Database

Teradata Database Introduction to Teradata

Teradata Database
Release Number
Content Type
User Guide
Publication ID
English (United States)
Last Update

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


This element…


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.


    bracketed and simple comments.

    Note: Nested bracketed comments are not allowed.

    For more information, see “SQL Stored Procedures as SQL Applications” on page 98.