hi all
my instalation: laz 0.9.24 beta and zeos 6.6.2 (under MS Vista)
i'm using firebird db server (not embedded) and i've already looked in this site about this topic... however i think there's something strange
i know using firebird, working with AutocommitMode = TRUE is good; i know too that StartTransaction escape from this setting and allow to work in "OFF MODE" until a commit or rollback explicit invocation.
so i use this code:
procedure TForm1.ExecuteSqlScript;
var sApp: string;
begin
sApp := 'script.sql';
if Memo1.Lines.Count = 0 then
Memo1.Lines.LoadFromFile(sApp);
ZSQLProcessor1.Script.Assign(Memo1.Lines);
cnConn.StartTransaction;
Try
ZSQLProcessor1.Execute;
Except
on e: exception do begin
Memo2.Lines.Add('error: ' + e.Message);
Memo2.Lines.Add(' rollback forced');
cnConn.Rollback;
Memo2.Lines.Add(' rollback done');
end;
End;
cnConn.Commit;
end;
the code above is ok but i can't avoid to the end user a "Invalid operation inAutocommit mode" message
i come from delphi and i've recently started using lazarus with zeos... so is that a zeos bug or a my-source-bug?
thanks
markbass72
Invalid operation in AutocommitMode
Moderators: gto, cipto_kh, EgonHugeist
-
- Fresh Boarder
- Posts: 13
- Joined: 06.04.2008, 10:16
- Location: Macerata
-
- Fresh Boarder
- Posts: 13
- Joined: 06.04.2008, 10:16
- Location: Macerata
reading carefully mdaems's and patyi's replies i think mistake is in my code
look at comments:
cnConn.StartTransaction;
Try
ZSQLProcessor1.Execute;
cnConn.Commit; // <- this is the correct place
Except
on e: exception do begin
Memo2.Lines.Add('error: ' + e.Message);
Memo2.Lines.Add(' rollback forced');
cnConn.Rollback;
Memo2.Lines.Add(' rollback done');
end;
End;
// <- in case of exception i think here, thanks to rollback,
// i'm already in "ON MODE"
//
// cnConn.Commit;
in can't run this code now but i'll test this as soon as possible (and i'll post the result
thanks
markbass72
look at comments:
cnConn.StartTransaction;
Try
ZSQLProcessor1.Execute;
cnConn.Commit; // <- this is the correct place
Except
on e: exception do begin
Memo2.Lines.Add('error: ' + e.Message);
Memo2.Lines.Add(' rollback forced');
cnConn.Rollback;
Memo2.Lines.Add(' rollback done');
end;
End;
// <- in case of exception i think here, thanks to rollback,
// i'm already in "ON MODE"
//
// cnConn.Commit;
in can't run this code now but i'll test this as soon as possible (and i'll post the result
thanks
markbass72
-
- Fresh Boarder
- Posts: 13
- Joined: 06.04.2008, 10:16
- Location: Macerata
-
- Fresh Boarder
- Posts: 13
- Joined: 06.04.2008, 10:16
- Location: Macerata