Combine records from one table whenever a value exists in a common field in another table.
Display inventory items the providing vendor who has been blocked.
InventTable inventTable;
VendTable vendTable;
;
ttsbegin;
while select forupdate inventTable
exists join vendTable
where vendTable.AccountNum == inventTable.PrimaryVendorId &&
vendTable.Blocked == CustVendorBlocked::All
{
inventTable.PrimaryVendorId ="";
inventTable.update();
}
ttscommit;
Display inventory items the providing vendor who has been blocked.
InventTable inventTable;
VendTable vendTable;
;
ttsbegin;
while select forupdate inventTable
exists join vendTable
where vendTable.AccountNum == inventTable.PrimaryVendorId &&
vendTable.Blocked == CustVendorBlocked::All
{
inventTable.PrimaryVendorId ="";
inventTable.update();
}
ttscommit;
Display only those customers which have at least one sales order in sales table.
Query query;
QueryBuildDatasource datasource,SalesDataSource,CustomerDataSource;
QueryRun queryrun;
CustTable custtable;
SalesTable salesTable;
query = new Query();
CustomerDataSource = query.addDataSource(tableNum(CustTable ));
SalesDataSource = CustomerDataSource.addDataSource(tableNum(SalesTable ));
SalesDataSource.joinMode(JoinMode::ExistsJoin );
SalesDataSource.relations(false);
SalesDataSource.addLink(fieldNum(CustTable, AccountNum),
fieldNum(SalesTable , CustAccount ));
queryrun = new QueryRun(query);
while(queryRun.next())
{
custtable = queryRun.get(tablenum(CustTable ));
Info(custtable.AccountNum);
}
No comments:
Post a Comment