Elements of an SQL Stored Procedure - Teradata Vantage - Analytics Database

Database Introduction

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
2025-11-21
dita:mapPath
gtm1628096154303.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dsm1472253642401
lifecycle
latest
Product Category
Teradata Vantageā„¢

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

Element Description
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 the following:
    • 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 the following:
    • Updatable or read-only.
    • Result set cursor for returning result set of SELECT statement run in stored procedure to caller or client application.
  • 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.