Inside Dynamics Axapta源代码赏析(五)
1.更改RecVersion
AX4.0使用了乐观并发控制,RecVersion是用来标识记录版本的。
{
CustTable custTableSelected;
CustTable custTableSelectedForUpdate;
CustTable custTableUpdated;
;
ttsbegin;
select custTableSelected
where custTableSelected.AccountNum == '4000';
select forupdate custTableSelectedForUpdate
where custTableSelectedForUpdate.AccountNum == '4000';
select forupdate custTableUpdated
where custTableUpdated.AccountNum == '4000';
// At this point, RecVersion in all three buffers are equal.
custTableUpdated.CreditMax = custTableUpdated.CreditMax;
custTableUpdated.update();
print custTableUpdated.recVersion;
print custTableSelectedForupdate.recVersion;
print custTableSelected.recVersion;
// At this point, RecVersion is changed in the custTableUpdated
// and custTableSelectedForUpdate buffers. CustTableSelected still
// has its original value in RecVersion.
ttscommit;
pause;
}
2.跳过ForUpdate和TTSbegin,TTSCommit的检查.
;
ttsbegin;
select custTable where custTable.AccountNum == '4000';
custTable.CreditMax = 1000;
custTable.skipTTSCheck(true);
custTable.update();
ttscommit;
这样是可以跳过,但为什么要跳过那?
3.临时表的使用.
通过setTmp和data两个方法可以搞定.
{
CustTable custTable;
CustTable custTableTmp;
;
custTableTmp.setTmp();
ttsbegin;
while select custTable
{
custTableTmp.data(custTable);
custTableTmp.doInsert();
}
ttscommit;
}
Table有两个方法,data()和setTmpData(),其中Data()是拷贝一份数据,而setTmpData()只是对象引用的传递.
4.临时表的清空
把临时表赋值为null的时候,内存被清空,临时文件被删除
{
TmpLedgerTable tmpLedgerTable;
;
tmpLedgerTable.CompanyId = 'dat';
tmpledgerTable.AccountNum = '1000';
tmpLedgerTable.AccountName = 'Name';
tmpLedgerTable.insert(); // Insert into first dataset.
tmpLedgerTable = null; // Allocated memory is freed
// and file is deleted.
tmpLedgerTable.CompanyId = 'dat';
tmpledgerTable.AccountNum = '1000';
tmpLedgerTable.AccountName = 'Name';
tmpLedgerTable.insert(); // Insert into new dataset.
//Check it
while select * from tmpLedgerTable
{
print tmpLedgerTable.AccountName;
}
pause;
}
5.下面的这段代码正好印证了前面的说法,setTmpData是指向同一个对象的.
{
TmpLedgerTable tmpLedgerTable1;
TmpLedgerTable tmpLedgerTable2;
;
tmpLedgerTable2.setTmpData(tmpLedgerTable1);
tmpLedgerTable1.CompanyId = 'dat';
tmpledgerTable1.AccountNum = '1000';
tmpLedgerTable1.AccountName = 'Name';
tmpLedgerTable1.insert(); // Insert into shared dataset.
tmpLedgerTable2.CompanyId = 'dat';
tmpledgerTable2.AccountNum = '1000';
tmpLedgerTable2.AccountName = 'Name';
tmpLedgerTable2.insert(); // Insert will fail with dublicate value.
}
6.ttsabort用于忽略记录的更改或插入.
剩下的代码都是一些关于事务和锁的问题,跟数据库的理论类似,这里就不摘录了.
转载于:https://www.cnblogs.com/Farseer1215/archive/2006/09/26/515340.html
Inside Dynamics Axapta源代码赏析(五)相关推荐
- Inside Dynamics Axapta源代码赏析(四)
第八章:Developing Applications Using Business Connector 这一章的代码主要演示如何通过Business Connector与Axapta交互 在Dyna ...
- Inside Dynamics Axapta源代码赏析(三)
第七章:Extending Dynamics Ax 使用该章的某些工程前需要在 系统管理->设置->电子邮件参数处 设置好相关的参数,当然如果不想用示例代码中的发邮件功能,可以将其注释掉 ...
- JSF 源代码赏析之Lifecycle
JSF 源代码赏析之Lifecycle 关键字: jsf sourcecode lifecycle JSF的生命周期在JSF应用中起着至关重要的作用,每一个JSF请求的处理都需要经过一次生命周期,本文 ...
- 从零学习VINS-Mono/Fusion源代码(五):VIO初始化
本节分析VIO初始化部分 VINS-Mono/Fusion代码学习系列: 从零学习VINS-Mono/Fusion源代码(一):主函数 从零学习VINS-Mono/Fusion源代码(二):前端图像跟 ...
- 微软ERP dynamics Axapta中的保留字
微软ERP dynamics Axapta中的保留字 Axapta中的保留字 作者:Farseer 看到一份微软的文档,介绍了Axapta中的保留字,把Axapta中特有的一些保留字和摘录如下: an ...
- 新鲜抓取古文赏析五千篇
新鲜抓取的古文,有感兴趣的可以来看看.-IT源点-古文赏析 外科精義 黄景昌-古诗文选集 鼎镌陈眉公先生批评西廂记 世醫得效方 汪炎昶-古诗文选集 至正条格 乐郊私语 敖氏傷寒金鏡錄 十四經發揮 宋史 ...
- 最优控制电池储能模型 蓄电池储能模型的最优控制python源代码 包含五个python脚本,它从data .csv读取价格、负载和温度数据。 然后用本文中描述的决策变量、目标和约束构造一个pyomo抽
最优控制电池储能模型 蓄电池储能模型的最优控制python源代码,代码按照高水平文章复现 包含五个python脚本,它从data .csv读取价格.负载和温度数据. 然后用本文中描述的决策变量.目标和 ...
- 代码之美——Doom3源代码赏析2
http://www.csdn.net/article/2013-01-17/2813778-the-beauty-of-doom3-source-code/2 摘要:Dyad作者.资深C++工程师S ...
- 代码之美——Doom3源代码赏析
摘要:Dyad作者.资深C++工程师Shawn McGrathz在空闲时翻看了Doom3的源代码,发出了这样的惊叹:"这是我见过的最整洁.最优美的代码!""Doom 3的 ...
最新文章
- 电气期刊论文实现:基于遗传优化的非侵入式居民负荷分解方法(有代码)
- mysql 云主机名_mysql部署到云主机的笔记
- iOS GoldRaccoon第三方FTP文件夹下载失败原因
- android 上下偏差怎么写_详解 Android 热更新升级如何突破底层结构差异?
- 网易云深度学习第一课第一周编程作业
- 深度学习之激活函数篇(Sigmoid、tanh、ReLU、PReLU)
- 对设计领域中Tile和Card的理解
- 百度SEO之-权重与排名(含工具网站)
- [转载]Altium Designer 破解,避免局域网冲突的ad9.ini
- 三点估算法_三点估算
- 使用Photoshop对图像进行二值化处理
- AlphaZero问世:8小时完爆围棋、国际象棋、日本将棋(转)
- 2022年机器视觉综述论文
- 新浪邮箱服务器设置,免费的新浪邮箱设置outlook怎么设置?
- 51单片机农历转换公历c语言算法,用51单片机实现公历与农历星期的转换
- ChatGPT实现代码生成
- 引擎磨合 (Break In) 的秘密
- 常用C++开发环境介绍
- PPT资料如何免费转成PDF
- el-rate的使用