AX2012 自带的数据库查询功能比较慢(特别是查询删除的情况),有些业务可能需要频繁查询删除人和删除时间等,这种情况下还是用代码来查询比较快。

例:

static void SysDataBaseLog_SalesTableDel(Args _args)
{
SysDataBaseLog sysDataBaseLog;
container tableRecord, tableRecordSel;
container recordInstance;
int idx = 0;
str fieldName,fieldValue_new,fieldValue_old;
SalesId salesId, salesIdDel;
utcDateTime beginDT, endDT;
TableId tableId;
str delby;
utcDateTime delDateTime;
; // return; salesIdDel = "XXXXXXXX"; // 被删除的SalesId
beginDT = 2021-12-20T00:00:00; // 开始时间, 时间范围越精确,查询所需时间越少
endDT = 2021-12-24T00:00:00; // 结束时间
tableId = tableName2id("SalesTable"); // 1. 先根据【SalesId】找出被删的记录
while select sysDataBaseLog
where sysDataBaseLog.table == tableId // Table的RecordId, 自行替换
&& sysDataBaseLog.LogType == DatabaseLogType::Delete // 要查询的数据库日志的类型, 自行替换
&& sysDataBaseLog.createdDateTime > beginDT // 开始时间
&& sysDataBaseLog.createdDateTime < endDT // 结束时间
{
tableRecord = sysDataBaseLog.Data;
if(tableRecordSel != conNull())
{
break;
} for(idx = 1; idx <= conLen(tableRecord); idx++)
{
recordInstance = conpeek(tableRecord, idx); fieldName = conpeek(recordInstance, 1); // container下记录的数据为为【fieldNmae】, 【字段更改前的数据】,【更改后的数据】... if(fieldName == "SalesId")
{
salesId = conpeek(recordInstance, 2); if(salesId == salesIdDel)
{
tableRecordSel = tableRecord;
delby = sysDataBaseLog.createdBy;
delDateTime = DateTimeUtil::applyTimeZoneOffset(sysDataBaseLog.createdDateTime, DateTimeUtil::getUserPreferredTimeZone());
break;
}
else
{ break;
}
}
}
} // 2. 循环读出记录字段
info(strFmt("删除日期和时间: %1", delDateTime));
info(strFmt("删除人: %1", delby));
for(idx = 1; idx <= conLen(tableRecordSel); idx++)
{
recordInstance = conpeek(tableRecordSel, idx); fieldName = conpeek(recordInstance, 1);
if(fieldName == "SalesId")
{
salesId = conpeek(recordInstance, 2);
info(strFmt("销售订单号:%1", salesId));
}
else if(fieldName == "createdBy")
{
info(strFmt("创建人: %1", conpeek(recordInstance, 2)));
}
else if(fieldName == "CreatedDateTime")
{
info(strFmt("创建日期和时间: %1", conpeek(recordInstance, 2)));
}
}
}

最新文章

  1. 《连载 | 物联网框架ServerSuperIO教程》- 9. 协议过滤器,解决一包多发、粘包、冗余数据
  2. Kruskal 最小生成树算法
  3. 自己动手写ORM框架
  4. Android 手势水平监听判断
  5. Android5.0新特性——Material Design简介
  6. 当Thread.Sleep的暂停时间参数设置过小时,精度很差的解决方法
  7. VS 6.00 工程项目文件详解
  8. 去掉display:inline-block元素间的多余空白
  9. UE 使用技巧
  10. Java 之 网络编程
  11. zabbix 模版其实就是主机
  12. 【Python的迭代器,生成器】
  13. mysql复习秘籍
  14. C# (类型、对象、线程栈和托管堆)在运行时的相互关系
  15. jQuery选择器概述
  16. centos查看apache用的是哪个httpd.conf
  17. redis 系列14 有序集合对象
  18. Linux 常用基本指令
  19. 006_netstat中state详解
  20. Oracle 用户,角色,权限等

热门文章

  1. js获取对象数组中指定属性值的新数据
  2. Day25:报告编写等
  3. comment out one line in the file with sed
  4. SpannableString 设置文字中的颜色 链接
  5. lua-1-c# 执行lua文件-调用lua文件中的方法
  6. onnxruntime源码解析之C接口实现
  7. 解决ubuntu18环境matplotlib无法正常显示中文
  8. download links
  9. HDLbits——Lfsr5
  10. [JSOI2015]圈地