Error to do Update, using the same ZConnection in a While
Posted: 01.08.2011, 20:38
Hello,
I still convert all programs, to ZeosLib 6.6.6, but i found a strange problemn, in this code, when the "Next" statement is called, but in DBX this code Works, and in many applications this logic are used, i do something wrong?
Thanks to all.
I still convert all programs, to ZeosLib 6.6.6, but i found a strange problemn, in this code, when the "Next" statement is called, but in DBX this code Works, and in many applications this logic are used, i do something wrong?
Code: Select all
procedure TFi000.btnClick(Sender: TObject);
var
query1 : TZReadOnlyQuery;
query2 : TZQuery;
begin
Cursor := crHourGlass;
query1 := TZReadOnlyQuery.Create(nil);
query2 := TZQuery.Create(nil);
query1.Connection := Dmaih.SQLDados;
query2.Connection := Dmaih.SQLDados;
query1.SQL.Clear();
query1.SQL.Add('select * from RDB$FIELDS');
query1.Open();
while not query1.Eof do begin
query2.Connection.StartTransaction();
query2.SQL.Clear();
query2.SQL.Add('update RDB$FIELDS set RDB$QUERY_NAME=:RDB$QUERY_NAME where RDB$FIELD_NAME=:RDB$FIELD_NAME');
query2.ParamByName('RDB$QUERY_NAME').AsString := query1.FieldByName('RDB$QUERY_NAME').AsString;
query2.ParamByName('RDB$FIELD_NAME').AsString := query1.FieldByName('RDB$FIELD_NAME').AsString;
query2.ExecSQL();
query2.Connection.Commit();
query1.Next();
end;
FreeAndNil(query1);
FreeAndNil(query2);
Cursor := crDefault;
end;