Fetch method inside transaction

Posts   
 
    
Posts: 34
Joined: 05-Mar-2008
# Posted on: 17-Jun-2011 13:15:03   

Hello,

I have got a general question about transaction, in this article: http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/Adapter/gencode_transactions_adapter.htm, there is an example:

Transaction.Begin() Fetch() Save() Transaction.Commit()

But, in this article: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=10823&HighLight=1 as a rule of thumb you advice: - read data first - then start transaction - only WRITE data during transactions - commit early

These two articles are inconsistent, could you explain this? Can Fetch method be include safely in transaction or not?

Regards, Dawid

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 17-Jun-2011 13:43:00   

The next line in the second link reads:

Do not fetch data during a transaction unless the transaction is very quick, but it's not recommended.

So you can read/fetch within a transaction, if you are sure it would be very quick, or if you want to apply read locks on these rows until the transaction ends.

But generally this is not recommended, as a good practice I always try to fetch outside of the Transaction, except in edge cases, when I want to lock these rows for reads until I finish.