• QueryBuildRange的空值使用


    不过为了系统将来的扩展性最好使用SysQuery::valueEmptyString();以免将来空值的含义发生变化。
    SysQuery::valueEmptyString();这个方法的注释也说明了把空置封装成方法的原因是为了将来的兼容性。

    用QueryBuildRange的value属性时,如果value的值是‘’,则查询会忽略该Range,好像没有这个Range一样,比如如下语句:

    用这种方式也可以达到一样的效果

    static void EmptyTest()
    {
        Query q;
        QueryRun qr;

        CustTable cust;
        ;
        q 
    = new Query();
        q.addDataSource(tableNum(custtable)).addRange(fieldnum(custtable,accountnum)).value(
    '');
        qr 
    = new QueryRun(q);
        
    while(qr.next())
        
    {
            cust 
    = qr.get(tablenum(custtable));
            box::info(cust.Address);
        }

        pause;

    }

    如果想查询某个字段的值为‘’值的该怎么处理那?这就需要用到SysQuery::valueEmptyString();如下所示:

    static void EmptyTest()
    {
        Query q;
        QueryRun qr;

        CustTable cust;
        ;
        q 
    = new Query();
        q.addDataSource(tableNum(custtable)).addRange(fieldnum(custtable,accountnum)).value(SysQuery::valueEmptyString());
        qr 
    = new QueryRun(q);
        
    while(qr.next())
        
    {
            cust 
    = qr.get(tablenum(custtable));
            box::info(cust.Address);
        }

        pause;

    }

    static void EmptyTest()
    {
        Query q;
        QueryRun qr;

        CustTable cust;
        ;
        q 
    = new Query();
        q.addDataSource(tableNum(custtable)).addRange(fieldnum(custtable,accountnum)).value(queryvalue(''));
        qr 
    = new QueryRun(q);
        
    while(qr.next())
        
    {
            cust 
    = qr.get(tablenum(custtable));
            box::info(cust.Address);
        }

        pause;

    }

    直接使用转义字符也可以,如:

    static void EmptyTest()
    {
        Query q;
        QueryRun qr;

        CustTable cust;
        ;
        q 
    = new Query();
        q.addDataSource(tableNum(custtable)).addRange(fieldnum(custtable,accountnum)).value("/'/'");
        qr 
    = new QueryRun(q);
        
    while(qr.next())
        
    {
            cust 
    = qr.get(tablenum(custtable));
            box::info(cust.Address);
        }

        pause;

    }

  • 相关阅读:
    PyPDF2 编码问题 PyPDF2.utils.PdfReadError Illegal character in Name Object
    使用PyPDF2结合pdfminer拆分PDF,并提取关键字重命名拆分出来的文件
    最全面的常用正则表达式大全
    idea setting
    java基础-静态,非静态(构造)代码块,类加载
    利用复制(分发订阅)延时计算业务数据
    sql server 数据库复制实现数据同步常见问题(不定期更新)
    api接口写好了?想过(Accept,Content-Type)?返回类型json|xml?
    install brew cask
    idea 找不到 没有 tomcat server
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2761601.html
Copyright © 2020-2023  润新知