DB2 Version 10.1 for Linux, UNIX, and Windows

Variables (PL/SQL)

Variables must be declared before they are referenced.

Variables that are used in a block must generally be defined in the declaration section of the block unless they are global variables or package-level variables. The declaration section contains the definitions of variables, cursors, and other types that can be used in PL/SQL statements within the block. A variable declaration consists of a name that is assigned to the variable and the data type of the variable. Optionally, the variable can be initialized to a default value within the variable declaration.

Procedures and functions can have parameters for passing input values. Procedures can also have parameters for passing output values, or parameters for passing both input and output values.

PL/SQL also includes variable data types to match the data types of existing columns, rows, or cursors using the %TYPE and %ROWTYPE qualifiers.