Declare local variables

You can define a variable to be either local or global in scope. This section describes local variables. In an SPL routine, local variables:
  • Are valid only for the duration of the SPL routine
  • Are reset to their initial values or to a value the user passes to the routine, each time the routine is executed
  • Cannot have default values
You can define a local variable on any of the following data types:
  • Built-in data types (except SERIAL, SERIAL8, BIGSERIAL, TEXT, or BYTE)
  • Any extended data type (row type, opaque, distinct, or collection type) that is defined in the database prior to execution of the SPL routine

The scope of a local variable is the statement block in which it is declared. You can use the same variable name outside the statement block with a different definition.

For more information on defining global variables, see Declare global variables.