local_declaration - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

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-06
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

You can specify these options for a local declaration.

DECLARE
Keyword introducing a local variable declaration, cursor declaration, or condition handler declaration statement.
DECLARE is followed by a list of local variables, a cursor specification, or a list of handler declarations.
You can specify multiple local variable declarations, cursor declarations, or condition handler declarations for each procedure.
See Teradata Vantage™ - SQL Stored Procedures and Embedded SQL, B035-1148 for details.
variable_name
data_type
[variable_name ]
[database_name | user_name ] table_name %ROWTYPE
Name and data type of the local variable being declared.
See SQL Fundamentals for the rules for naming database objects.
Any number of local variables of the same data type can be specified as a comma-separated list. These variable names are replaced by data values during execution.
Local variables can have UDT and %ROWTYPE data types.
The %ROWTYPE attribute dynamically creates an implicit data type based on the structure of a base table or global temporary table row in table_name. The table_name variable cannot refer to a volatile table.
DEFAULT
Optional keyword for introducing a default value for the local variables.
If more than one local variable is specified along with a default value, that value applies to all of the local variables in the list.
literal
The literal must be compatible with the data type specified.
You can only specify a literal or NULL, not an expression.
NULL
Default value for the variables.
A variable is initialized to NULL if no default value is specified.
condition_name
Name for the declared condition that can be used to associate a symbolic condition name with a specific SQLSTATE value.
See Teradata Vantage™ - SQL Fundamentals, B035-1141 for the rules for naming database objects.
sqlstate_code
SQLSTATE value assigned to condition_name.