Assign values to variables

Within an SPL routine, use the LET statement to assign values to the variables you have already defined.

If you do not assign a value to a variable, either by an argument passed to the routine or by a LET statement, the variable has an undefined value.

An undefined value is different from a NULL value. If you attempt to use a variable with an undefined value within the SPL routine, you receive an error.

You can assign a value to a routine variable in any of the following ways:
  • Use a LET statement.
  • Use a SELECT INTO statement.
  • Use a CALL statement with a procedure that has a RETURNING clause.
  • Use an EXECUTE PROCEDURE INTO or EXECUTE FUNCTION INTO statement.