TZConnection is always in transaction state

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 13.11.2013, 08:54

Re: TZConnection is always in transaction state

Postby Artem_ » 19.11.2013, 09:57

Hi. To get explicit transactions control im using another way:
I call server to start transaction before any edits starting

Code: Select all

{before opening some editor form}
ZDBConnection1.ExecuteDirect('START TRANSACTION;');

after this you should execute query to lock required object
executing that queries should be inside try-except block
If you caught exception - it mean that another user locked it
before you. In this way you should call
ZDBConnection1.ExecuteDirect('ROLLBACK;'); to cancel waste
transaction and prevents exceptions
Btw if all OK you are free to do any editing using edit-insert-post metods
Now to save all edited data you need to execute
ZDBConnection1.ExecuteDirect('COMMIT;'); at editing end.
Remember that things:
1. Till you called SQL Commit or Rollback another users will freeze trying to edit same rows(tables), that was locked. So you should check records(table) with NOWAIT SQL option
before try to edit it. If objects were locked - the exception will raise, not application freezes.
2. Calling post/applyUpdates and others DataSets methods would not affect physical database until you call COMMIT SQL commend
3. DBConnection method StartTransaction, Commit, and Rollback will do nothing in this way
Sorry for mistakes. Im NOT Englishman)

Return to “6.6 - stable”

Who is online

Users browsing this forum: No registered users and 1 guest