AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 21.12.2007, 12:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,510 / 847 (80) +++++++
Регистрация: 28.10.2006
Holzheys: X++ Transactions, exceptions and updateconflicts.
Источник: http://holzhey.isa-geek.com/blog/pos...conflicts.aspx
==============

In September, I posted an article on x++ transactions unique behaviors. I am following up now with another case where they are even more unique, and where it is an exception to the transaction exception behavior.

In the event that you running under a transaction and in nested try-catch blocks the catch block nearest to a updateconflict exception that catches that exception is allowed to correct that error and continue.
Example code below:

X++:
   1:     static void RetrysWithException()
   2:      {
   3:          CustTable custTable;
   4:         int retryCount;
   5:         ;
   6:   
   7:   
   8:         ttsbegin; 
   9:   
  10:   
  11:   
  12:   
  13:         select forupdate custTable where custTable.AccountNum == 'S135' && custTable.CustGroup == '00';
  14:         retryCount = 0;
  15:   
  16:   
  17:   
  18:   
  19:         try // The ttslevel for this try-catch block is one
  20:         {
  21:                 custTable.CreditRating = strfmt("%1",str2int(custTable.CreditRating)+1);
  22:                 custTable.update(); // The UpdateConflict will be thrown inside this method. 
  23:                 info(strfmt("CreditRating = %1", custTable.CreditRating));
  24:         }
  25:         catch (Exception::UpdateConflict) 
  26:         {
  27:                 if( retryCount < 4)
  28:                 {
  29:                     retryCount ++;
  30:   
  31:   
  32:   
  33:   
  34:                     // reread the row without rolling back the transaction
  35:                     custTable.reread();
  36:                     retry;
  37:                 } else // no more than 5 retries allowed;
  38:                    // may be the business logic requires a try here
  39:                           if (appl.ttslevel() == 0)
  40:                      retry;
  41:                   else
  42:                       throw Exception::UpdateConflict;
  43:                 }
  44:             }
  45:         ttscommit; 
  46:      }
Источник: http://holzhey.isa-geek.com/blog/pos...conflicts.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:43.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.