Static invocation of a select-statement

A select-statement can be included as a part of the (nonexecutable) statement DECLARE CURSOR.

Such a statement is executed every time the cursor is opened by means of the (embedded) statement OPEN. After the cursor is open, the result table can be retrieved one row at a time by successive executions of the FETCH statement or multiple rows at a time by using the multiple-row FETCH statement.

Used in this way, the select-statement can contain references to variables. These references are effectively replaced by the values that the variables have at the moment of executing OPEN.