Implicit and explicit statement blocks
In an SPL routine, the implicit statement block extends
from the end of the CREATE statement to the beginning of the END statement.
You can also define an explicit statement block, which
starts with a BEGIN statement and ends with an END statement, as the
following figure shows.
The explicit statement block allows you to define variables or processing that are valid only within the statement block. For example, you can define or redefine variables, or handle exceptions differently, for just the scope of the explicit statement block.
The
SPL function in the following figure has an explicit statement block
that redefines a variable defined in the implicit block.
In this example, the implicit statement block defines
the variable distance and gives it a value of 37
.
The explicit statement block defines a different variable named distance and
gives it a value of 2
. However, the RETURN statement
returns the value stored in the first distance variable, or 37
.