第十二章 The Database layer
1.更改RecVersion
AX4.0使用了乐观并发控制,RecVersion是用来标识记录版本的。

static void RecVersionChange(Args _args)
{
    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的检查.

 CustTable custTable;
    ;
    ttsbegin;
    select custTable where custTable.AccountNum == '4000';
    custTable.CreditMax = 1000;

    custTable.skipTTSCheck(true);
    custTable.update();
    ttscommit;

这样是可以跳过,但为什么要跳过那?
3.临时表的使用.
通过setTmp和data两个方法可以搞定.

static void TmpCustTable(Args _args)
{
    CustTable custTable;
    CustTable custTableTmp;
    ;
    custTableTmp.setTmp();
    ttsbegin;
    while select custTable
    {
        custTableTmp.data(custTable);
        custTableTmp.doInsert();
    }
    ttscommit;
}

Table有两个方法,data()和setTmpData(),其中Data()是拷贝一份数据,而setTmpData()只是对象引用的传递.
4.临时表的清空
把临时表赋值为null的时候,内存被清空,临时文件被删除

static void TmpLedgerTable(Args _args)
{
    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是指向同一个对象的.

static void TmpLedgerTable(Args _args)
{
    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源代码赏析(五)相关推荐

  1. Inside Dynamics Axapta源代码赏析(四)

    第八章:Developing Applications Using Business Connector 这一章的代码主要演示如何通过Business Connector与Axapta交互 在Dyna ...

  2. Inside Dynamics Axapta源代码赏析(三)

    第七章:Extending Dynamics Ax 使用该章的某些工程前需要在 系统管理->设置->电子邮件参数处  设置好相关的参数,当然如果不想用示例代码中的发邮件功能,可以将其注释掉 ...

  3. JSF 源代码赏析之Lifecycle

    JSF 源代码赏析之Lifecycle 关键字: jsf sourcecode lifecycle JSF的生命周期在JSF应用中起着至关重要的作用,每一个JSF请求的处理都需要经过一次生命周期,本文 ...

  4. 从零学习VINS-Mono/Fusion源代码(五):VIO初始化

    本节分析VIO初始化部分 VINS-Mono/Fusion代码学习系列: 从零学习VINS-Mono/Fusion源代码(一):主函数 从零学习VINS-Mono/Fusion源代码(二):前端图像跟 ...

  5. 微软ERP dynamics Axapta中的保留字

    微软ERP dynamics Axapta中的保留字 Axapta中的保留字 作者:Farseer 看到一份微软的文档,介绍了Axapta中的保留字,把Axapta中特有的一些保留字和摘录如下: an ...

  6. 新鲜抓取古文赏析五千篇

    新鲜抓取的古文,有感兴趣的可以来看看.-IT源点-古文赏析 外科精義 黄景昌-古诗文选集 鼎镌陈眉公先生批评西廂记 世醫得效方 汪炎昶-古诗文选集 至正条格 乐郊私语 敖氏傷寒金鏡錄 十四經發揮 宋史 ...

  7. 最优控制电池储能模型 蓄电池储能模型的最优控制python源代码 包含五个python脚本,它从data .csv读取价格、负载和温度数据。 然后用本文中描述的决策变量、目标和约束构造一个pyomo抽

    最优控制电池储能模型 蓄电池储能模型的最优控制python源代码,代码按照高水平文章复现 包含五个python脚本,它从data .csv读取价格.负载和温度数据. 然后用本文中描述的决策变量.目标和 ...

  8. 代码之美——Doom3源代码赏析2

    http://www.csdn.net/article/2013-01-17/2813778-the-beauty-of-doom3-source-code/2 摘要:Dyad作者.资深C++工程师S ...

  9. 代码之美——Doom3源代码赏析

    摘要:Dyad作者.资深C++工程师Shawn McGrathz在空闲时翻看了Doom3的源代码,发出了这样的惊叹:"这是我见过的最整洁.最优美的代码!""Doom 3的 ...

最新文章

  1. 电气期刊论文实现:基于遗传优化的非侵入式居民负荷分解方法(有代码)
  2. mysql 云主机名_mysql部署到云主机的笔记
  3. iOS GoldRaccoon第三方FTP文件夹下载失败原因
  4. android 上下偏差怎么写_详解 Android 热更新升级如何突破底层结构差异?
  5. 网易云深度学习第一课第一周编程作业
  6. 深度学习之激活函数篇(Sigmoid、tanh、ReLU、PReLU)
  7. 对设计领域中Tile和Card的理解
  8. 百度SEO之-权重与排名(含工具网站)
  9. [转载]Altium Designer 破解,避免局域网冲突的ad9.ini
  10. 三点估算法_三点估算
  11. 使用Photoshop对图像进行二值化处理
  12. AlphaZero问世:8小时完爆围棋、国际象棋、日本将棋(转)
  13. 2022年机器视觉综述论文
  14. 新浪邮箱服务器设置,免费的新浪邮箱设置outlook怎么设置?
  15. 51单片机农历转换公历c语言算法,用51单片机实现公历与农历星期的转换
  16. ChatGPT实现代码生成
  17. 引擎磨合 (Break In) 的秘密
  18. 常用C++开发环境介绍
  19. PPT资料如何免费转成PDF
  20. el-rate的使用

热门文章

  1. 好程序员web前端分享数组及排序、去重和随机点名
  2. shell脚本将本地docker镜像push到阿里云镜像仓库
  3. 树状数组模板1——单点修改区间查询
  4. Task三个列子的分享
  5. 《Elasticsearch in Action》书评与作者访谈
  6. POJ 3237 Tree (树链剖分)
  7. Java编程中写出好代码的建议
  8. 数据流和十六进制转换
  9. Linux 下 zip unzip压缩与解压
  10. 大话Django之一:安装与启动