Hi experts,
I want to create the corresponding AND conditions in a while loop.
but when while loop run, the condition is OR
I want AND instead of OR.
Anyone help me?
Thank all.
*This post is locked for comments
Hi.
Please use the following code.
// I feel addRange should be outside whileloop as we dont want to create range for every record
queryBuildRange = qbdsFinancialTag.addRange(fieldNum(DimensionFinancialTag, Value));
while(SetEnumerator.moveNext()) { queryBuildRange.value(strFmt('((Value == %1) || (Value == "%2"))', queryValue("01"), queryValue("02"))); }
Thanks,
Chaitanya Golla
The same field cannot simultaneously have 2 different values, so what good is AND as you have explained it?
You want OR to allow for multiple values. For example, WHERE VALUE IN (N'01',N'02') is identical to WHERE (VALUE = N'01' OR VALUE = N'02'). Perhaps you might express in natural language that you want to select records for value of 01 "and" 02, but in SQL the AND clause means both clauses must be true at the same time, and there are no records where (VALUE = N'01' AND VALUE = N'02'), it's impossible.
I see also that your query snippet uses NOT, is that part of a NOT EXISTS sub-query? Perhaps that changes what you mean when you say you want AND?
Hi Chaitanya and Sukrut
Thank for your rep, but I am adding range in while loop, so I can not use the expression that you provide.
Hi Brandon, I think you understand my problem.
For more infomation, I try override method lookup. I want to lookup all value in table DimensionFinancialTag and
I also want to exclude some values of the DimensionFinancialTag table from my setup, so I use NOT.
Therefore, I want use AND in my query.
Removed.
Try this
Query q; QueryBuildDataSource qbds; QueryBuildRange qbr; ; q = new Query(); qbds = q.addDataSource(tableNum(CustTable)); qbr = qbds.addRange(fieldNum(CustTable, AccountNum)); qbr.value(SysQuery::valueNot('A') + ',' + SysQuery::valueNot('B'));
gives
SELECT * FROM CustTable(CustTable_1) WHERE ((NOT (AccountNum = N'A') AND NOT (AccountNum = N'B')))
Since you have a loop, you'll have to construct a single concatenated string and then assign that string to a single QueryBuildRange object, but I think it will work.
Hi Brandon,
I tried:
And successful.
The issue close.
Thank for your help.
Make sure you mark all helpful answers as Verified next to each post to resolve the thread.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Tocauer 4
Community Member 2
Nayyar Siddiqi 2