Declaring local variables of type row
Variables of type row can be declared once the row data type has been created.
Before you create a row data type:
- Read: Row types
- Read: Restrictions on the row data type
Row data type variables can only be declared in SQL PL contexts including SQL procedures and functions where execution of the DECLARE statement is supported.
The following steps must be followed to declare a local row variable:
- Formulate a declare statement:
- Specify a name for the variable.
- Specify the row data type that will define the variable. The specified row data type must be already defined in the database.
DECLARE r1 empRow; - Execute the DECLARE statement within a supported context.
If execution of the DECLARE statement is successful, the row variable is created.
Upon creation of a row variable each field in the row is initialized to a NULL value.
The row variable can be assigned values, be referenced, or passed as a parameter.