DECLARE Examples - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Example: Specifying Declaration

The declaration is completely specified:

DECLARE hErrorMsg CHARACTER(30) DEFAULT 'NO ERROR';

Example: Specifying Multiple Local Variables of the Same Data Type

Multiple local variables of the same data type can be specified in one declaration statement.

The following declaration declares both hAccountNo and tempAccountNo to be INTEGER. No default is specified for either variable; therefore NULL is assigned as the default for both.

DECLARE hAccountNo, tempAccountNo INTEGER;

The following statement declares the data types of hLastName and hFirstNameto be CHARACTER(30).

DECLARE hFirstName, hLastName CHARACTER(30);

Example: Assigning a Default Value for Each Local Variable

A default value can be assigned for each local variable specified in a declaration.

In the following example, a default value of 'NO ERROR' is explicitly assigned to hNoErrorMsg and hErrorMsg:

DECLARE hNoErrorMsg, hErrorMsg CHARACTER(30) DEFAULT 'NO ERROR';

Example: Declaring the Variable MyCircle

The following DECLARE statement declares the variable MyCircle, which has the structured UDT type CircleUdt, to have a default value determined by the constructor external routine named circle with input parameters of 1, 1, and 9:

DECLARE MyCircle CircleUdt DEFAULT NEW circle(1,1,9);

Example: Declaring hBirthdate as DATE Data Type

The following statement declares hBirthdate to be of DATE data type with a default value of '1998-01-06'.

DECLARE hBirthdate DATE DEFAULT '1998-01-06';