zoukankan      html  css  js  c++  java
  • dynamics Ax 2009 实现 union 效果

    Ax中多表关联仅提供Inner Join/Outer Join/Exist join/Not Exist join,而么有union,可以通过Query来实现.

    例如 Sql:

    select ItemType,GoodsName from table1 where TransDate between g_DateB and g_DateE
    union
    select ItemType,GoodsName from table2 where TransDate between g_DateB and g_DateE

    1 实现[ from table1 ]
        qbd = query.addDataSource(tableNum(table1));
    2 实现[ select ItemType,GoodsName ]
        qbd.addSelectionField(fieldnum(table1,ItemType));
        qbd.addSelectionField(fieldnum(table1,GoodsName));
    3 实现[ where TransDate between g_DateB and g_DateE ]
      qbd.addRange(fieldnum(table1,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));
    4 实现[ union ]
        query.queryType(QueryType::Union);
      
    代码:
       Query query;
        QueryRun qr;
        QueryBuildDataSource qbd;
        QueryBuildDataSource qbd2;
        Table1 newTable;

        qbd = query.addDataSource(tableNum(table1));
        qbd.addSelectionField(fieldnum(table1,ItemType));
        qbd.addSelectionField(fieldnum(table1,GoodsName));
        qbd.addRange(fieldnum(table1,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));

        qbd2 = query.addDataSource(tablenum(table2));
        qbd2.addSelectionField(fieldnum(table2,ItemType));
        qbd2.addSelectionField(fieldnum(table2,GoodsName));
        qbd2.addRange(fieldnum(table2,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));


        qbd2.addRange(fieldnum(table2,RecId)).
                value(strfmt("((%1 > %2) || (%3 > %4) || (%5 > %6))",
                fieldstr(table2,Qty),queryValue(0),
                fieldstr(table2,Weight),queryValue(0),
                fieldstr(table2,Volume),queryValue(0)));// OR Condition

        query.queryType(QueryType::Union);
        qr = new QueryRun(query);
        while(qr.next())
        {
         newTable = qr.get(tableNum(table1));
         //do something...
      }

    非有希望才坚持,坚持才会有希望
  • 相关阅读:
    Linux du命令
    log
    为什么基址不会变?
    游戏辅助分类
    什么是nProtect?
    Linux启动过程详解
    Restorator 2018 v3.90汉化注册版 含注册码汉化激活教程
    LoadLibrary(C:softIDA 7.0IDA 7.0pluginspython64.dll) error: 找不到指定的模块。 C:softIDA 7.0IDA 7.0pluginspython64.dll: can't load file LoadLibrary(C:softIDA 7.0IDA 7.0pluginspython64.dll) erro
    windows 安装python2.7
    ida 下载
  • 原文地址:https://www.cnblogs.com/eugenewu0808/p/2160914.html
Copyright © 2011-2022 走看看