| View previous topic :: View next topic |
| Author |
Message |
Craig Stuntz [TeamB] Guest
|
Posted: Fri Dec 12, 2003 5:46 pm Post subject: Re: Is rollback necessary here? |
|
|
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
|
Posted: Fri Dec 12, 2003 5:56 pm Post subject: Is rollback necessary here? |
|
|
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
|
Posted: Fri Dec 12, 2003 6:18 pm Post subject: Re: Is rollback necessary here? |
|
|
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
|
Posted: Fri Dec 12, 2003 6:34 pm Post subject: Re: Is rollback necessary here? |
|
|
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 |
|
 |
|