BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Verify Transaction

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Jed Nicolau Filho
Guest





PostPosted: Fri Dec 10, 2004 8:41 pm    Post subject: Verify Transaction Reply with quote



Hello Dear Friends

Is it a good pratice to verify SQLConnection.InTransaction before Commit
and before RollBack with DBExpress ?
Or It is not necessary ?
************************
If Not SQLConnection.InTransaction then
Begin
TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SQLConnection.StartTransaction(TD);
Try
Close;
SQL.Clear;
SQL.Add( SQLStatement );
ExecSql;
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Commit(TD); {on success, commit the changes}
Except
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Rollback(TD); {on failure, undo the changes}
End;
************************

Thanks in advance

Best Regards

Jed


Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Fri Dec 10, 2004 9:41 pm    Post subject: Re: Verify Transaction Reply with quote



Jed Nicolau Filho wrote:
Quote:

Is it a good pratice to verify SQLConnection.InTransaction before
Commit and before RollBack with DBExpress ?
Or It is not necessary ?
************************
SQLConnection.StartTransaction(TD);
Try
Close;
SQL.Clear;
SQL.Add( SQLStatement );
ExecSql;
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Commit(TD); {on success, commit the changes}
Except
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Rollback(TD); {on failure, undo the changes}
End;

That should not be necessary. The transaction is under your control and will
not change arbitraily. Even if the call to ExecSQL were to raise an
exception (e.g. a bad SQL statement), the transaction would not be affected.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"Democracy, without the guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman



Back to top
Bill Todd
Guest





PostPosted: Fri Dec 10, 2004 9:48 pm    Post subject: Re: Verify Transaction Reply with quote



The disadvantage of testing the InTransaction property is that you
probably want to know if you are not in a transaction when you should
be.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
Back to top
Jed Nicolau Filho
Guest





PostPosted: Sat Dec 11, 2004 12:16 am    Post subject: Re: Verify Transaction Reply with quote

Thanks Wayne and Bill

Ok. That's it.

Best Regards

Jed

"Jed Nicolau Filho" <jed (AT) prouser (DOT) com.br> escreveu na mensagem
news:41ba0961 (AT) newsgroups (DOT) borland.com...
Quote:
Hello Dear Friends

Is it a good pratice to verify SQLConnection.InTransaction before Commit
and before RollBack with DBExpress ?
Or It is not necessary ?
************************
If Not SQLConnection.InTransaction then
Begin
TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SQLConnection.StartTransaction(TD);
Try
Close;
SQL.Clear;
SQL.Add( SQLStatement );
ExecSql;
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Commit(TD); {on success, commit the
changes}
Except
If SQLConnection.InTransaction then
//<-------------------------THIS
SQLConnection.Rollback(TD); {on failure, undo the
changes}
End;
************************

Thanks in advance

Best Regards

Jed





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.