Tag: SQL

SQL in X++, range in where clause

Below case is when ‘AccessFeedsFilter’ has value it should fetch that reocrds only if its empty: it should fetch all

 

while select SKUNumber, ItemId, inventDimId,LifeCycleStatusFlag,ItemName, InboundDepth, InboundHeight, InboundWeight, InboundWidth,
OutboundDepth, OutboundHeight, OutboundWeight, OutboundWidth, ActualDepth, ActualHeight, ActualWeight, ActualWidth, RetailVariantId, Description, BasePrice
from productsAndVariants
where (productsAndVariants.LifeCycleStatusFlag == ogoParameters.AccessFeedsFilter && ogoParameters.AccessFeedsFilter != “”) || (ogoParameters.AccessFeedsFilter == “” && true)

 

 

************* compare 2 fields. if not same only get data ***********

qbr = SysQuery::findOrCreateRange(this.parmQuery().dataSourceTable(tablenum(DRF_VendTransVendInvoiceJourView)),

fieldnum(DRF_VendTransVendInvoiceJourView,CostLedgerVoucher),fieldnum(DRF_VendTransVendInvoiceJourView,Voucher));

qbr.value(strFmt(‘(%1 != %2)’,

fieldStr(DRF_VendTransVendInvoiceJourView, CostLedgerVoucher),

fieldStr(DRF_VendTransVendInvoiceJourView, Voucher)));

Advertisements