我有这个 SQL 语句:
从 AX2009_DEV.dbo.WMSINVENTTRANSDOCK 中选择 * 在 INVENTTRANSREFID 上加入 AX2009_DEV.dbo.SALESTABLE = salesid 在 WMSINVENTTRANSDOCK.inventDimId 上加入 AX2009_DEV.dbo.INVENTDIM = inventDim.inventDimId
我正在尝试用代码写这个:
qbdWMSInventTransDock = query.addDataSource(tableNum(WMSInventTransDock));
qbdSalesTable = qbdWMSInventTransDock.addDataSource(tableNum(SalesTable));
qbdSalesTable.addLink(fieldNum(WMSInventTransDock, InventTransRefId), fieldNum(SalesTable, SalesId));
qbdSalesTable.joinMode(JoinMode::InnerJoin);
qbdInventDim = qbdWMSInventTransDock.addDataSource(tableNum(InventDim));
qbdInventDim.addLink(fieldNum(WMSInventTransDock, InventDimId), fieldNum(InventDim, InventDimId));
qbdInventDim.joinMode(JoinMode::InnerJoin);
但是当我调试时,只要我尝试将 InventDim 连接到 WMSInventTransDock,就可以看到 SQL 语句“重置”。
我想这样做而不是编写选择语句,因为我希望以后能够这样做:
if (inventSiteId)
{
qbr = qbdInventDim.addRange(fieldNum(InventDim, InventSiteId));
qbr.value(inventSiteId);
}
if (inventLocationId)
{
qbr = qbdInventDim.addRange(fieldNum(InventDim, InventLocationId));
qbr.value(inventLocationId);
}