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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.11.2007, 20:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
staticsax: New approach to Exceptions and Transactions handling
Источник: http://staticsax.blogspot.com/2007/1...l-support.html
==============

As much as I like the transactional support in the core of the X++ language, as much I dislike the connection between exception handling and transactions.
In my opinion transaction should be part of the syntax and have syntax based scope.
Here is my suggestion to Microsoft:

1) ban the standalone ttsbegin and ttscommit
2) replace it with special try-catch syntax , as drafted below:
try(new Connection())
{ //implicit TTSbegin
[do your stuff]

} //implicit TTScommit
catch(Exception::Error)
{ //implicit TTSabort.
[oops]

}
Both Oracle and MSSQL2005 support the nested transactions, and that would be ideal opportunity to use it.
conn = new Connection();
try(conn)
{ //implicit TTSbegin = BEGIN TRANS LEVEL1
try(conn)
{ //implicit TTSbegin = BEGIN TRANS LEVEL2
SalesFormLetterInvoice::post(SalesTable);
} //implicit TTScommit = COMMIT TRANS LEVEL2
catch(Exception::Error)
{ //implicit TTSabort = ROLLBACK TRANS LEVEL2
if(..cannot compensate the error...)
throw Error(....)
else
[compensate the error.]
}
} //implicit TTScommit = COMMIT TRANS LEVEL1
catch(Exception::Error)
{ //implicit TTSabort = ROLLBACK TRANS LEVEL1
[...]

}
That way each try-catch block is eligible to work, not only this started outside of transaction, and when needed each of them can operate own (sub) transaction.
It is also much less demanding on the developer, preventing improper or unbracketed use of ttsbegin and ttscommit. Normal (non db) try-catch bloack work as usually, allowing to catch X++ and CLR exceptions without unwanted rollbacks.


Источник: http://staticsax.blogspot.com/2007/1...l-support.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Issues concerning X++: Exception handling and transactions Blog bot DAX Blogs 1 14.02.2009 00:46
Holzheys: X++ Transactions, exceptions and updateconflicts. Blog bot DAX Blogs 2 10.10.2008 01:23
staticsax: Real world processing: TTS and exceptions Blog bot DAX Blogs 0 20.08.2007 11:50
SysDictCoder: Axapta error handling and database transactions Blog bot DAX Blogs 0 28.10.2006 16:47
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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