References to SQL statement names
The name of an SQL statement can be the same as the name of another SQL statement declared in the same routine.
This can occur when the two SQL statements are declared in different
compound statements. The compound statement that contains the declaration
of an SQL statement name determines the scope of that statement name.
A statement name must be unique within the compound statement in which
it is declared, excluding any declarations in compound statements
that are nested within that compound statement (SQLSTATE 42734). A
statement name can only be referenced within the compound statement
in which it is declared, including any compound statements that are
nested within that compound statement. When there is a reference to
a statement name, the statement that is declared in the innermost
compound statement is the statement that is used. For more information,
see Compound SQL (inlined)
.