function IPDOStatement.nextRowSet: Boolean;
This function advances to the next rowset in a multi-rowset statement handle. Some database servers support stored procedures that return more than one rowset (also known as a result set). IPDOStatement.nextRowSet enables you to access the second and subsequent rowsets associated with a IPDOStatement object. Each rowset can have a different set of columns from the preceding rowset.
Return Values
Returns TRUE on success or FALSE on failure.
Example
Example 1. Fetching multiple rowsets returned from a stored procedure
The following example shows how to call a stored procedure, MULTIPLE_RESULTS, that returns three rowsets. We use repeat loop to loop over the IPDOStatement.nextRowset method, which returns false and terminates the loop when no more rowsets can be returned.
procedure example1; var i: integer; sql: AnsiString; rowset: TPDORowSetNative; begin rowset := TPDORowSetNative.create; sql := 'CALL multiple_rowsets'; stmt := db.query_as_is(sql); i := 1; repeat stmt.fetch_all (rowset); printResultSet(rowset, i); i := i + 1; until not stmt.nextRowset; rowset.free; end; procedure (rowset: TPDORowSetNative; counter: Integer); var numRows, currentRow: Int64; numCols, currentCol: Byte; begin writeln (format('Result set %d', [counter])); numRows := Length(rowset.row); for currentRow := 0 to numRows - 1 do begin numCols := rowset.row[currentRow].ColumnCount; for currentCol := 0 to numCols - 1 do write (rowset.row[currentRow].column[currentCol].asString + chr(9)); writeln (''); end writeln(''); end;
The above example will output:
Result set 1: apple red banana yellow Result set 2: orange orange 150 banana yellow 175 Result set 3: lime green apple red banana yellow