![]() |
#1 |
Участник
|
Query ranges OR condition
Hi,
The following code sample: Query q = new Query(); QueryBuildDataSource qbds; ; qbds = q.addDataSource(tablenum(Table1)); SysQuery::findOrCreateRange(qbds, fieldnum(Table1, Field1)).value(a); SysQuery::findOrCreateRange(qbds, fieldnum(Table1, Field2)).value(b); Both ranges for Field1 and Field2 works as AND expression. Is it possible somehow handle those ranges as OR expression, between those fields? |
|
![]() |
#2 |
MCT
|
AND and OR clauses
This example will help you.
You may use both clauses in one expression. X++: queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3) && (%4 == "%5")))', fieldStr(InventTable, ItemType), any2int(ItemType::Service), any2int(ItemType::Item), fieldStr(InventTable, ProjCategoryId), queryValue("Spares")));
__________________
Axapta book for developer |
|
![]() |
#3 |
Участник
|
Thanks
|
|
![]() |
#4 |
Участник
|
Цитата:
Сообщение от MikeR
![]() This example will help you.
You may use both clauses in one expression. X++: queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3) && (%4 == "%5")))', fieldStr(InventTable, ItemType), any2int(ItemType::Service), any2int(ItemType::Item), fieldStr(InventTable, ProjCategoryId), queryValue("Spares"))); |
|
![]() |
#5 |
Участник
|
That's not quite correct, it works for other field types, too, but you have to format literals in a slightly different way. E.g. string literals must be enclosed in double quotes and dates must be formatted in X++ way (yyyy\mm\dd).
|
|
![]() |
#6 |
Участник
|
Цитата:
Query q = new Query(); QueryBuildDataSource qbds; QueryRun qr; QueryBuildRange qbr; CustTable custTable; ; qbds = q.addDataSource(tablenum(CustTable)); qbr = SysQuery::findOrCreateRange(qbds, fieldnum(CustTable, AccountNum)); qbr.value(strfmt('((%1 == %2) || (%3 == %4))', fieldStr(CustTable, AccountNum),"000015", fieldStr(CustTable, InvoiceAccount),"000023")); qr = new QueryRun(q); if (qr.prompt()) { while (qr.next()) { custTable = qr.get(tablenum(CustTable)); info(strfmt("AccountNum: %1; InvoiceAccount: %2", custTable.AccountNum, custTable.InvoiceAccount)); } } |
|
![]() |
#7 |
Участник
|
String literals must be enclosed in double quotes
![]() X++: // ... qbr.value(strfmt('((%1 == "%2") || (%3 == "%4"))', // ... |
|
![]() |
#8 |
Участник
|
|
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|