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 

Is rollback necessary here?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Craig Stuntz [TeamB]
Guest





PostPosted: Fri Dec 12, 2003 5:46 pm    Post subject: Re: Is rollback necessary here? Reply with quote



Brad Wood wrote:

Quote:
RollbackTrans // do I need this even though no data changed?

No; a commit will do.

-Craig

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
How to ask questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html

Back to top
Brad Wood
Guest





PostPosted: Fri Dec 12, 2003 5:56 pm    Post subject: Is rollback necessary here? Reply with quote



New to transactions, using SqlServer2K I am doing the following and I am not
sure whether to call rollback at a certain point

BeginTrans
try
call stored proc
if stored proc returns true begin
if some other stuff returns true
CommitTrans
else
RollbackTrans
end else begin
// This will mean that no data was changed //
RollbackTrans // do I need this even though no data changed?
end
except
RollbackTrans
end

I am wondering whether the RollbackTrans that I am calling when the stored
proc returns false (no data changed) is necessary. I don't know if it's
completely safe to call rollback when no changes have been made.


Back to top
Ross B.
Guest





PostPosted: Fri Dec 12, 2003 6:18 pm    Post subject: Re: Is rollback necessary here? Reply with quote



Once you have begun a transaction you must end the transaction. The only way
to end the transaction using the TADOConnection is to either commit or
rollback.

"Brad Wood" <bwood (AT) colorflex (DOT) com> wrote

Quote:
New to transactions, using SqlServer2K I am doing the following and I am
not
sure whether to call rollback at a certain point

BeginTrans
try
call stored proc
if stored proc returns true begin
if some other stuff returns true
CommitTrans
else
RollbackTrans
end else begin
// This will mean that no data was changed //
RollbackTrans // do I need this even though no data changed?
end
except
RollbackTrans
end

I am wondering whether the RollbackTrans that I am calling when the stored
proc returns false (no data changed) is necessary. I don't know if it's
completely safe to call rollback when no changes have been made.





Back to top
Bill Todd (TeamB)
Guest





PostPosted: Fri Dec 12, 2003 6:34 pm    Post subject: Re: Is rollback necessary here? Reply with quote

As a general rule, always end transactions with commit unless there is
some reason to rollback. If no data was changed there is no reason to
rollback.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) 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.