Hello
I have two table : table1 and table2
ZQuery1 = table1
ZQuery2 = table2
After post a new record in ZQuery1 (table1) i'd like to modify something in ZQuery2 (table2) in ZQuery1.afterpost event.
Is it possible to do it in one transaction ?
And rollback the changes in ZQuery1 and ZQuery2 if something wrong happen in ZQuery2 ?
ZQuery1.table1afterpost(.........)
begin
ZQuery2.Edit;
ZQuery2FiledX.value:='xxx';
ZQuery2.Post; //if happen something wrong here what can i do to rollback all changes in ZQuery1 ?
end;
thank you in advance
Attila
ZQuery in transaction
Re: ZQuery in transaction
Sorry I use FireBird SQL 2.5
Re: ZQuery in transaction
@k1attila1
ZConnection1.StartTransaction;
...
...
ZConnection1.Commit;
or
ZConnection1.Rollback;
Michal
ZConnection1.StartTransaction;
...
...
ZConnection1.Commit;
or
ZConnection1.Rollback;
Michal
Re: ZQuery in transaction
Thank you miab3
But i edit table1 in dbgrid.
After post a record in the grid , i would like to made some changes in table2, in table1.afterpost eventhandler.
If there is something wrong happen in table1.afterpost i would like to rollback all changes in table2 and table1.
thank you
Attila
But i edit table1 in dbgrid.
After post a record in the grid , i would like to made some changes in table2, in table1.afterpost eventhandler.
If there is something wrong happen in table1.afterpost i would like to rollback all changes in table2 and table1.
thank you
Attila
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZQuery in transaction
You might want to check wether it makes sense to start a transaction in the before post event and commit or roll back it in the after post event. Unfortunately if you have to roll it back you would have to close and open your query, I think. Something alon these lines...
With best regards,
Jan
With best regards,
Jan
Re: ZQuery in transaction
Hello Jan
Thank you
Maybe i found a solution :
ZConnection.Autocommit:=false;
and i use
manual commit and rollback :
ZConnection.Commit or ZConnection.Rollback
Thnak you Attila
Thank you
Maybe i found a solution :
ZConnection.Autocommit:=false;
and i use
manual commit and rollback :
ZConnection.Commit or ZConnection.Rollback
Thnak you Attila