|
![]() |
#1 |
MCT
|
X++: table t1,t2; ttsbegin; while select t1 { select forupdate t2 where t2.recid == t1.RecId; ..... t2.update(); } ttscommit;
__________________
Axapta book for developer Последний раз редактировалось MikeR; 18.07.2012 в 16:45. |
|
![]() |
#2 |
Участник
|
Цитата:
В чем в этом варианте большая корректность перед первоначальным?
__________________
Axapta v.3.0 sp5 kr2 |
|
![]() |
#3 |
MCT
|
Цитата:
aEremenko: Ресурс заблокирован, ждите...
__________________
Axapta book for developer Последний раз редактировалось MikeR; 18.07.2012 в 18:29. Причина: поважнее будет |
|
![]() |
#4 |
Участник
|
Вы не находите, что приведенная ссылка не имеет никакого отношения к исходному утверждению (потому как в нем не было никакой речи о закрытии/открытии транзакции внутри цикла)?
В вашем же примере получается только увеличение времени выполнения выполнения за счет лишних запросов к базе.
__________________
Axapta v.3.0 sp5 kr2 |
|
![]() |
#5 |
MCT
|
Цитата:
Значит вы не поняли или не смог я вам объяснить. ![]()
__________________
Axapta book for developer |
|
![]() |
#6 |
MCT
|
Цитата:
X++: While select Statement with Large Transaction Scope ttsBegin; while select ItemId from salesLine { select firstOnly forUpdate ItemType, ItemBuyerGroupId from inventTable where inventTable.ItemId == salesLine.ItemId; If (inventTable && (inventTable.ItemType == InventItemType::Item)) { inventTable.ItemBuyerGroupId = ; inventTable.update(); } } ttsCommit; To limit the transaction scope, the code should be written to begin the transaction when the following criteria is met: While select Statement with Appropriate Transaction Scope while select ItemId from salesLine { select firstOnly forUpdate ItemType, ItemBuyerGroupId from inventTable where inventTable.ItemId == salesLine.ItemId; If (inventTable && (inventTable.ItemType == InventItemType::Item)) { ttsBegin; inventTable.ItemBuyerGroupId = ; inventTable.update(); ttsCommit; } } DO: Limit the transaction scope by grabbing locks at the latest possible time and releasing locks as early as possible.
__________________
Axapta book for developer Последний раз редактировалось MikeR; 21.01.2014 в 19:41. |
|
|
|