Does it make sense to declare a transaction for a query that is only
performing a data read.
for example:
BEGIN tran
select * from pubs..authors
if @.@.error <> 0
Begin
ROLLBACK tran
raiserror('blah', 16,1)
RETURN
END
COMMIT
My thinking is that if there is an error on reading, than the client will
anyway get the error message, so adding an explicit transaction may be
addding overhead.Why would you need a transaction? You have nothing to rollback?
-- Jesse
"MG" <y4forums.t.mdgoyal@.xoxy.net> wrote in message
news:%235nPdDsDFHA.148@.TK2MSFTNGP14.phx.gbl...
> Does it make sense to declare a transaction for a query that is only
> performing a data read.
> for example:
> BEGIN tran
> select * from pubs..authors
> if @.@.error <> 0
> Begin
> ROLLBACK tran
> raiserror('blah', 16,1)
> RETURN
> END
> COMMIT
> My thinking is that if there is an error on reading, than the client will
> anyway get the error message, so adding an explicit transaction may be
> addding overhead.
>|||> Does it make sense to declare a transaction for a query that is only
> performing a data read.
No, It does not make sense.
AMB
"MG" wrote:
> Does it make sense to declare a transaction for a query that is only
> performing a data read.
> for example:
> BEGIN tran
> select * from pubs..authors
> if @.@.error <> 0
> Begin
> ROLLBACK tran
> raiserror('blah', 16,1)
> RETURN
> END
> COMMIT
> My thinking is that if there is an error on reading, than the client will
> anyway get the error message, so adding an explicit transaction may be
> addding overhead.
>
>|||On Wed, 9 Feb 2005 11:03:19 -0500, MG wrote:
>Does it make sense to declare a transaction for a query that is only
>performing a data read.
Hi MG,
Not in the default isolation mode (read committed). In repeatable read or
serializable mode, it does make sense.
You don't need the rollback, though.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Sunday, March 11, 2012
Declaring explicit transaction for a select stmt.
Labels:
authorsif,
database,
declare,
declaring,
examplebegin,
explicit,
microsoft,
mysql,
onlyperforming,
oracle,
pubs,
query,
select,
sense,
server,
sql,
stmt,
transaction,
transelect
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment