English 中文(简体)
tsbegin, tscommit 和 "~" 运算符
原标题:ttsbegin, ttscommit and "~" operator
  • 时间:2012-05-23 14:34:01
  •  标签:
  • axapta
  • x++

我学习X++,我有两个问题:

I don t understand what is the utility of ttsbegin and ttscommit ! where i must use it and what s the utility?

X++标准:ttsBegin和ttsCommit AX 2012

这个操作员"~"有什么用?

最佳回答

http://msdn.microsoft.com/en-us/library/aa622564.aspx" rel=“noreferrer”>文件:

tsBegin : 标记交易的开始。 这将确保数据的完整性, 并保证在交易结束前( 通过 ttsCommit )进行的所有更新( 全部或无) 一致( 全部或无) 。

tsCommit : 标记交易的成功结束。 这将结束并进行交易。 MorphX 保证实施的交易将按意向进行。

请注意

通常最好使用例外处理而不是 tsAbort 。丢弃语句自动中止当前交易 。

这意味着您将以 ttsBegin 开始交易,并以 ttsCommit (如果成功)结束交易,或者放弃例外(如果交易失败)。文档中不清楚,但交易意味着操作应用程序表格。

当您想要确保您在应用表格上的阅读或更新操作不会因同时发生的其他表格操作而出现不一致时,您会使用这些操作。

见同一链接的例子。

"http://msdn.microsoft.com/EN-US/library/aa870833" rel="noreferr"\code /code > 操作员 不是位数, 以整数翻转每个位数。例如, (假设32位整数): FFFFFFFFFF (每个位数现在为1), FFFFFFFB (十六进制代表)。

问题回答

使用 tsbegin 当您如何访问表格中的数据时, 它会告知系统到 DB 的交易将会发生 。
当您在一行中更新/ 保存数据时, 您必须调用 tscommitted, 否则这些更改会恢复到原始值, 类似您使用 C#/ VB 中的数据集时, 您必须告诉数据集才能将所有更改承诺到数据库 。

tsbegin就像 BEGIN SQL 声明, tscommitted就像 COMIT SQL 声明。

You Have to use them together:
ttsbegin;
add code here to retrieve data and manipulate data
ttscommit;

You are aloud to nest ttsbegins and ttscommits, but BE CAREFUL of multiple use of the above as not closing one ttsbegin can screw up a lot of things and I have found that calling ttsbegin and ttscommit once is enough.

至于~,我从来没有在 X++ 编码为 Axapta (微软动力AX) 的两年里使用过它。





相关问题
Axapta: Programmatically switch records in a form

In Dynamics AX 2009, how do you programmatically change to a different record in a form? My form contains a treeview and a group of bound data fields. When clicking on a record in the tree (the data ...

Dynamics AX 2009 - Duplicate IDs

We are in the process of merging projects from different AX Servers into source control on the same AX server. However, a few object IDs are common between projects, so Dynamics throws an error when ...

How to show a row total amount by group CG Group in Report

I am using Axapta 3.0 with language X++. I am making a report based on available report. The new report only shows a total row by group CG Group instead of showing all detail row as old report. Exam:...

Axapta: Form lifecycle question

I am attempting to manually populate an image icon into a window nested in a grid. In the run event, the fields don t appear to have values yet. The string control always returns an empty value. Is ...

How to reference a report datasource table using x++

I m unable to find the proper syntax for referencing the CustInvoiceTrans table of the SalesInvoice report datasource. Here s the context: I ve created a new classification field on the ...

axapta thread / animation

i have a function which costs plenty of time. this function is an sql-query called via odbc - not written in x++, since the functional range is insufficient. while this operation is running, I want ...

Axapta Validation Class

I ve written a method to handle regex validation in AX2009. Problem is that it always returns false, no matter what the expression or input string. Returns no errors, just false Mind taking a ...

ERP What to read/practice?

I had been learning ERP applications this summer during internship. As I am a programmer about to graduate, I want to have a solid software branch that would get me through till I am sure about what ...