Wednesday, 11 July 2018

How to Use LIKE Operator in select Query X++

It is very common to use Like Operator in SQL 

SELECT column1, column2, ...
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;
                    
                }
            }
            
        }
    }
}

Azure Hosted pipeline - Update Artifacts (NuGet) for version update

 Step-by-Step Guide to Updating or Creating Artifacts for a Hosted Pipeline In this blog, we’ll walk you through the process of updating or ...