Result set locator variables

A result set locator variable is a variable that contains the locator that identifies a stored procedure result set. A result set locator variable in an SQL statement must identify a result set locator variable described in the program according to the rules for declaring result set locator variables. This is always indirectly through an SQL statement.

For example, in C: Start of change
     static volatile SQL TYPE IS RESULT_SET_LOCATOR VARYING *loc1;
End of change

A result set locator variable in an SQL procedure is defined with the RESULT_SET_LOCATOR VARYING clause in a compound statement.

The meta-variable rs-locator-variable, as used in the syntax diagrams, shows a reference to a result set locator variable. A host variable that is a result set locator variable can have an association indicator variable. When the indicator variable that is associated with a result set locator is null, the referenced result set is not defined.

If a result set locator variable does not currently represent any stored procedure result set, an error occurs when the locator variable is referenced.

A commit operation destroys all open cursors that were declared in the stored procedure without the WITH HOLD option and the result set locators that are associated with those cursors. Otherwise, a cursor and its associated result set locator persist past the commit.

An application that is written in a programming language other than Java can access a result set that is returned from a stored procedure. A result set locator is used by the invoking application to access the result set. A result set locator value for a result set can be obtained from an ASSOCIATE LOCATOR statement or with the DESCRIBE PROCEDURE statement. For more information, see ASSOCIATE LOCATORS and DESCRIBE PROCEDURE.

The result set locator value is specified on an ALLOCATE CURSOR statement to define a cursor in the invoking application and to associate it with a stored procedure result set. For more information, see ALLOCATE CURSOR.

A DESCRIBE CURSOR statement can be used in the invoking application to obtain information on the characteristics of the columns of a stored procedure result set. For more information, see DESCRIBE CURSOR.

The application can then access the rows of the result set using FETCH statements with the allocated cursor.