Row-Producing Procedures¶
A row-producing procedure is a database procedure that can return zero or more rows to its caller.
Format of a Row-Producing Procedure¶
The RESULT ROW clause in the procedure definition defines the format of a row-producing procedure. The RETURN ROW statement specifies the value returned in each “column” of a result row. The value can be a local variable or parameter of the procedure, or any expression involving constants, local variables, and parameters. The local variables must contain data retrieved in the procedure by a SELECT statement. Multiple result rows must be returned to the caller using the For-loop that retrieves data from a SELECT statement.
How a Row-Producing Procedure Is Called¶
Row-producing procedures can only be called directly from an embedded SQL host program (not using dynamic SQL, a terminal monitor, or by nesting a call in another database procedure). The host program, however, must include a Begin/End block to process the rows as they are returned from the procedure. This block functions much the same as the “select block” used with embedded SELECT statements.
A row-producing procedure cannot execute another procedure.