RAD Studio |  |

Fetching Multiple Result Sets
See Also
Collapse All

Some stored procedures return multiple sets of records. The dataset only fetches the first set when you open it. If you are using TSQLStoredProc or TADOStoredProc, you can access the other sets of records by calling the NextRecordSet method:

Copy Code

    var
      DataSet2: TCustomSQLDataSet;
    begin
      DataSet2 := SQLStoredProc1.NextRecordSet;
      ...

Copy Code

    TCustomSQLDataSet *DataSet2 = SQLStoredProc1->NextRecordSet();

In TSQLStoredProc, NextRecordSet returns a newly created TCustomSQLDataSet component that provides access to the next set of records. In TADOStoredProc, NextRecordset returns an interface that can be assigned to the RecordSet property of an existing ADO dataset. For either class, the method returns the number of records in the returned dataset as an output parameter.

The first time you call NextRecordSet, it returns the second set of records. Calling NextRecordSet again returns a third dataset, and so on, until there are no more sets of records. When there are no additional cursors, NextRecordSet returns nil.

See Also

Executing Stored Procedures That Don't Return a Result Set

Preparing Stored Procedures

Working with Stored Procedure Parameters

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!