• get record count of form datasource


    modified class : SysQuery

    public client server static Integer countTotal(QueryRun _queryRun,int num = 1)//add datasource num
    {
        container c = SysQuery::countPrim(_queryRun.pack(false),num);

        return conpeek(c,1);
    }

    private server static container countPrim(container _queryPack,int num = 1)//add datasource num
    {
        Query                   countQuery;
        QueryRun                countQueryRun;
        QueryBuildDataSource    qbds;
        QueryBuildFieldList     qbfl;
        Common                  common;
        Integer                 counter;
        Integer                 loops;
        ;
        countQueryRun   = new QueryRun(_queryPack);
        countQuery      = countQueryRun.query();
        qbds            = countQuery.dataSourceNo(num);//put datasource num
        qbds.update(false);
        qbds.sortClear();
        qbfl = qbds.fields();
        qbfl.dynamic(false);
        qbfl.clearFieldList();
        //if (countQuery.dataSourceCount() == 1)  //remark this
            qbds.addSelectionField(fieldnum(Common,RecId),SelectionField::Count);

        countQueryRun   = new QueryRun(countQuery);

        while (countQueryRun.next())
        {
            common  = countQueryRun.get(countQuery.dataSourceNo(num).table());//put datasource num
            counter += common.RecId;
            loops++;
        }

        return [counter,loops];
    }

    usage:

        Query query;
        QueryRun queryRun;
        ;
        query =new query();

        query.addDataSource(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum)).value(queryRange('000001','000008'));


        queryRun = new QueryRun(query);
        info(strfmt('%1',SysQuery::countTotal(queryRun)));

  • 相关阅读:
    springboot以jar运行时参数传递
    linux 下ab压力测试
    Quartus 11生成pof文件在AS烧写之后,程序无法启动
    芯片底层热焊盘的焊接
    CC3200模块的内存地址划分和bootloader,启动流程(二)
    python开发记录第一篇
    windows下使用Python出现No module named tkinter.ttk
    Pycharm设置Python的路径
    Qsys配置生成nios系统模块
    sprintf()函数使用异常
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/1963596.html
Copyright © 2020-2023  润新知