|
|
|
Вопрос с 70-229
|
|||
|---|---|---|---|
|
#18+
Сегодня сдавал 70-229. Там был такой вопрос You are a database developer for a clothing retailer. The company has a database named Sales. This database contains a table named Inventory. The Inventory table contains the list of items for sale and the quantity available for each of those items. When sales information is inserted into the database, this table is updated. The stored procedure that updates the inventory table is shown below: CREATE PROCEDURE UpdateInventory @IntID int AS BEGIN DECLARE @Count int BEGIN TRAN SELECT @Count = Available FROM Inventory WITH (HOLDLOCK) WHERE InventoryID = @IntID IF (@Count > 0) UPDATE Inventory SET Available = @Count – 1 WHERE InventoryID = @IntID COMMIT TRAN END When this procedure executes, the database server occasionally returns the following error message: Transaction (Process ID 53) was deadlock on {lock} resources with another process and has been chosen as the deadlock victim. Rerun the transaction. You need to prevent the error message from occurring while maintaining data integrity. What should you do? A. Remove the table hint. B. Change the table hint to UPDLOCK. C. Change the table hint to REPEATABLEREAD. D. Set the transaction isolation level to SERIALIZABLE. E. Set the transaction isolation level to REPEATABLE READ. Я выбрал B. Тем не менее, мне интересно кто какой ответ считает правильным и почему? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.08.2002, 20:02:21 |
|
||
|
Вопрос с 70-229
|
|||
|---|---|---|---|
|
#18+
Описание UPDLOCK из BOL: UPDLOCK: Use update locks instead of shared locks while reading a table, and hold locks until the end of the statement or transaction. UPDLOCK has the advantage of allowing you to read data (without blocking other readers) and update it later with the assurance that the data has not changed since you last read it. Очевидно, что это то, что нам нужно - прочитать данные из таблицы НИКОГО НЕ БЛОКИРУЯ, и сразу же заблокировать нужную часть таблицы НА ЗАПИСЬ пока вы не закончите update. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.08.2002, 21:19:50 |
|
||
|
Вопрос с 70-229
|
|||
|---|---|---|---|
|
#18+
Что значит прочитать НИКОГО НЕ БЛОКИРУЯ и одновременно заблокировать НА ЗАПИСЬ? Если мы блокируем НА ЗАПИСЬ - разве это не значит что мы не хотим чтобы оттуда читали, пока мы не закончим запись. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.08.2002, 12:26:17 |
|
||
|
|

start [/forum/topic.php?fid=46&fpage=3435&tid=1821133]: |
0ms |
get settings: |
10ms |
get forum list: |
13ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
34ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
25ms |
get tp. blocked users: |
1ms |
| others: | 238ms |
| total: | 335ms |

| 0 / 0 |
