FireDAC.Comp.Client.TFDAdaptedDataSet.NextRecordSet

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure NextRecordSet;

C++

void __fastcall NextRecordSet();

Properties

Type Visibility Source Unit Parent
procedure
function
public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDAdaptedDataSet

Description

Go to the next cursor, returned by the SQL command.

The NextRecordSet method closes the current cursor, forwards it to the next accessible cursor and opens the dataset. If there are no more accessible cursors, the dataset is closed after the call. See the Command Batches chapter for more details.

The Close method closes the current cursor. The call to the CloseAll method discards all associated cursors. So, to get all cursors, you should set FetchOptions.AutoClose to False before opening a dataset.

For FireDAC the REF CURSOR command in Oracle and PostgreSQL is a command for the cursor, and a call to NextRecordSet selects the next REF CURSOR parameter. For SQL Server, Sybase SQL Anywhere, MySQL, etc., a call to NextRecordSet selects the next result set, which is produced by the batch, the stored procedure or by other means.

At design time, you can forward the dataset to the next cursor, by right clicking the component and choosing the "Next record set" popup menu item. See the Executing Commands chapter for more details.

Example

ADQuery1.FetchOptions.AutoClose := False;
ADQuery1.SQL.Text := 'select 1 as i; select ''qwe'' as s';
ADQuery1.Open;
ShowMessage(ADQuery1.Fields[0].FieldName + ' ' + ADQuery1.Fields[0].AsString); // output "i 1"
ADQuery1.NextRecordSet;
ShowMessage(ADQuery1.Fields[0].FieldName + ' ' + ADQuery1.Fields[0].AsString); // output "s qwe"
ADQuery1.Close;

See Also