X++使用Insert/Update/Delete处理数据

  • 2021-10-27
  • Admin

一.Insert:

1.insert_recodeset

对于单表进行数据插入可以直接使用insert_recodeset,如果数据源来自多张表使用join进行连接,

insert_recodeset官方文档:
官方文档
如果有数据来源不是在相关的源表中,可以声明一个变量,在select中直接使用。
示例:

table table1;
table table2;
str A1;
insert_recordset Table1(A
                            ,B
                            ,C
                            ,D
                            ,E
                            ,F)
            select  A1,
                    B1,
                    C1,
                    D1,
                    E1,
                    F1
            from Table2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

2.while select调用insert()

二.Update的两种方式:

1.while select forupdate

官方文档:官方文档

2.update_recordset

官方文档:官方文档

三.Delete:

删除使用Delete_From,
官方文档:官方文档

在进行数据操作的时候应该尽可能的使用insert_recodeset和update_recodeset,以insert为例,插入14311行数据时,到SQL后端的次数while select为14213次,insert
_recodeset为6次,使用的SQL后端时间从174秒减少到10秒,是17倍,整体时间减少幅度更大因为新方法几乎不使用来自客户端或应用程序对象服务器 (AOS) 的资源。

原文:https://blog.csdn.net/m0_46115516/article/details/120996582

联系站长

QQ:769220720