Re: Quick question re: locks and triggers
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/05/04
- Next message: Aaron [SQL Server MVP]: "Re: find sequence of numbers"
- Previous message: Hugo Kornelis: "Re: @@NESTLEVEL"
- In reply to: Steve: "Quick question re: locks and triggers"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 05 Aug 2004 16:09:32 +0200
On Thu, 5 Aug 2004 06:17:22 -0700, Steve wrote:
>Hi all,
>
>Just learning about triggers and have a quick question.
>An insert statement holds an exclusive lock whilst the new
>row is written. What happens to the lock when an AFTER
>INSERT trigger is involved ?? Does the trigger hold the
>exclusive lock until it has terminated and the result
>returned to the client ??
>
>ie: is it therefore impossible for another process to
>insert until the trigger has finished it's work ??
>
>thanks
>Steve
Hi Steve,
The lock is not held by the insert statement or by the trigger, but by the
transaction. The lock will only be released when the transaction is either
committed or rolled back. Since the execution of the trigger is always
part of the same transaction as the execution of the statement that fired
the trigger, the answer is: yes, the lock will be held until the trigger
has finished.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Aaron [SQL Server MVP]: "Re: find sequence of numbers"
- Previous message: Hugo Kornelis: "Re: @@NESTLEVEL"
- In reply to: Steve: "Quick question re: locks and triggers"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|