QueryBuildRange的空值使用
不过为了系统将来的扩展性最好使用SysQuery::valueEmptyString();以免将来空值的含义发生变化。
SysQuery::valueEmptyString();这个方法的注释也说明了把空置封装成方法的原因是为了将来的兼容性。
在用QueryBuildRange的value属性时,如果value的值是‘’,则查询会忽略该Range,好像没有这个Range一样,比如如下语句:
用这种方式也可以达到一样的效果
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
如果想查询某个字段的值为‘’值的该怎么处理那?这就需要用到SysQuery::valueEmptyString();如下所示:
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://farseer1215.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
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;
}