13.02.2019, 12:42 | #1 |
Участник
|
динамический X++ запрос range по нескольким полям
Добрый ден,
Столкнулся с трудностями при переписывании данного SQL запроса: X++: while select BOMId from bomVersion group by routeOpr.IsTechnReasonable_ICL,bom.ItemId,ecoResProduct.RecId where bomVersion.ItemId==itemIdProduction && bomVersion.Active == NoYes::Yes && bomVersion.FromQty == #bomVersionFromQty && ( (bomVersion.FromDate==dateNull() && bomVersion.ToDate == dateNull())|| (bomVersion.FromDate<= systemDateGet() && bomVersion.ToDate >= systemDateGet())|| (bomVersion.FromDate<= systemDateGet() && bomVersion.ToDate == dateNull()) ) X++: ( (bomVersion.FromDate==dateNull() && bomVersion.ToDate == dateNull())|| (bomVersion.FromDate<= systemDateGet() && bomVersion.ToDate >= systemDateGet())|| (bomVersion.FromDate<= systemDateGet() && bomVersion.ToDate == dateNull()) X++: bomVersion.FromDate <= systemDateGet() && (bomVersion.ToDate == dateNull() || bomVersion.ToDate >= systemDateGet()) X++: static void Job74(Args _args) { Query query; Queryrun qr; QueryBuildDataSource qbdsBomVersion; BOMVersion bomVersion; query = new Query(); qbdsBomVersion = query.addDataSource(tableNum(BOMVersion)); qbdsBomVersion.addRange(fieldNum(BOMVersion,ItemId)).value(queryValue("7075")); qbdsBomVersion.addRange(fieldNum(BOMVersion,Active)).value(queryvalue(SysQuery::value(NoYes::Yes))); qbdsBomVersion.addRange(fieldNum(BOMVersion,FromQty)).value(queryValue("1")); qbdsBomVersion.addRange(fieldNum(BomVersion,FromDate)).value(strfmt("((%1.%2 <= %5) && ((%1.%3 == %4) || (%1.%3 >= %5)))", qbdsBomVersion.name(),fieldstr(BOMVersion,FromDate),fieldStr(BOMVersion,ToDate),date2strXpp(dateNull()),systemDateGet())); qr = new QueryRun(query); info(qr.query().dataSourceNo(1).toString()); X++: bomVersion.FromDate <= systemDateGet() && (bomVersion.ToDate == dateNull() || bomVersion.ToDate >= systemDateGet()) X++: qbdsBomVersion.addRange(fieldNum(BomVersion,FromDate)).value(strfmt("((%1.%2 <= %5) && ((%1.%3 == %4) || (%1.%3 >= %5)))", qbdsBomVersion.name(),fieldstr(BOMVersion,FromDate),fieldStr(BOMVersion,ToDate),date2strXpp(dateNull()),systemDateGet())); Возвращаемый SQL запрос такой: X++: SELECT * FROM BOMVersion(BOMVersion_1) WHERE ((ItemId = N'7075')) AND ((Active = 1)) AND ((FromQty = 1.E0)) AND ((((BOMVersion_1.FromDate <= 13.02.2019) && ((BOMVersion_1.ToDate == 01\01\1900) || (BOMVersion_1.ToDate >= 13.02.2019))))) https://docs.microsoft.com/en-us/dyn...n-query-ranges Заранее спасибо. Последний раз редактировалось dark_knight; 13.02.2019 в 13:04. |
|