This only works when you use SVN Testing branch version 228 or higher.
[syntax="delphi"]
procedure TForm1.Button1Click(Sender: TObject);
var conn: IZConnection;
stmt: IZStatement;
rs: IZResultSet;
updateCount: integer;
s, SQL: string;
begin
ZConnection.Properties.Add('CLIENT_MULTI_STATEMENTS=1');
ZConnection1.Connect;
conn := ZConnection1.DbcConnection;
stmt := conn.CreateStatement;
SQL := 'SELECT field1 t1_fld from table_2; ' +
'SELECT field1 t1_fld from table_1; ' +
'insert into table_2 (field1) values (''pretest''); ' +
'insert into table_1 (field1) values (''the contents''); ' +
'insert into table_2 (field1) values (''test'');';
s := '';
if stmt.Execute( SQL ) then begin
repeat
rs := stmt.GetResultSet;
if (rs <> nil) and rs.First then begin
if s <> '' then s := s + '; ';
s := s + rs.GetString(1);
end else begin
updateCount := stmt.GetUpdateCount;
if s <> '' then s := s + '; ';
s := s + IntToStr(updateCount);
end;
until not stmt.GetMoreResults and (stmt.GetUpdateCount = -1);
end;
stmt := nil;
MessageBox(Application.Handle, PChar(s), 'multiresults test', MB_OK);
end;
[/syntax]