Opens next rowset in the statement.
function OpenNext: boolean;
Call the OpenNext method to get the second and other ResultSets while executing a multiresult query. If DataSet opens, it returns True. If there are no record sets to be represented, it will return False, and the current record set will be closed. Has effect only for the ctDefaultResultSet cursor. The OpenNext method isn't compatible with TCustomDADataSet.Prepare.
Here is a small piece of code that demonstrates the approach of working with multiple datasets returned by a multi-statement query:
MSQuery.SQL.Clear; MSQuery.SQL.Add('SELECT * FROM Table1;'); MSQuery.SQL.Add('SELECT * FROM Table2;'); MSQuery.SQL.Add('SELECT * FROM Table3;'); MSQuery.SQL.Add('SELECT * FROM Table4;'); MSQuery.SQL.Add('SELECT * FROM Table5;'); MSQuery.FetchAll := False; MSQuery.Open; repeat // < do something > until not MSQuery.OpenNext;