It is very common to use Like Operator in SQL
SELECT column1, column2, ...
FROM table_name
FROM table_name
WHERE columnN LIKE pattern;
Now we will see how we can use the Like operator in X++
It is very similar to SQL as shown in the below example. In this example, I'm updating TrvPartyEmployeeRelationship with HcmWorker table.
static void MK_TrvPartyEmpUpd(Args _args)
{
DataArea dataArea;
TrvPartyEmployeeRelationship empRelation;
HcmWorker worker;
HcmPersonnelNumberId empName;
while select dataArea
where dataArea.isVirtual == NoYes::No
{
changeCompany(dataArea.id)
{
empRelation = null;
while select forUpdate empRelation
{
worker = null;
empName = "";
empName = strFmt("%1%2%3","*",empRelation.DEL_EmplId,"*");
select firstOnly worker
where worker.PersonnelNumber like empName;
if (worker.RecId)
{
ttsBegin;
empRelation.selectForUpdate(true);
empRelation.Worker = worker.RecId;
empRelation.doDelete();
ttsCommit;
}
}
}
}
}
No comments:
Post a Comment