查询范围不等于零 [英] Query range not equal to zero

查看:77
本文介绍了查询范围不等于零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AX 2012 R2环境中.

I'm in AX 2012 R2 environment.

我想向HcmEmployment表添加查询范围,并过滤出LegalEntity值= 0的行.

I would like to add a query range to HcmEmployment table and filter out rows that have a LegalEntity value = 0.

以下代码在运行时失败,但无效范围"除外.

The following code fails at runtime with the exception "Invalid Range".

qbrLegalEntity = qbds.addRange(fieldNum(HcmEmployment, LegalEntity));
strRangeCondition = '(%1 != %2)';
qbrLegalEntity.value(strFmt(strRangeCondition, 
                        fieldStr(HcmEmployment, LegalEntity),
                        queryValue("0")));

是否可以对此范围条件进行编码?

Is it possible to code this range condition?

谢谢.

推荐答案

别再难了:

qbds.addRange(fieldNum(HcmEmployment,LegalEntity)).value(SysQuery::valueNot(0));

查询表达式失败的原因是使用queryValue("0")引用了零.将其更改为0也可以,但又太费力了.

The reason for your failed query expression was the use of queryValue("0") which quotes the zero. Changing that to 0 would work as well, but again too laborious.

更短的是:

qbds.addRange(fieldNum(HcmEmployment,LegalEntity)).value('!0');

要诊断查询错误,请查看生成的SQL:

To diagnose query errors take a look on the SQL generated:

info(qbds.toString());

这篇关于查询范围不等于零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆