web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Joins in X++

(0) ShareShare
ReportReport
Posted on by 292

How do I convert following sql into x++?

/*INNER JOIN PURCHTABLE ON PURCHLINE.PURCHID = PURCHTABLE.PURCHID

and PURCHLINE.DATAAREAID = PURCHTABLE.DATAAREAID

and PURCHLINE.PARTITION = PURCHTABLE.PARTITION

LEFT JOIN INVENTDIM ON PURCHLINE.INVENTDIMID = INVENTDIM.INVENTDIMID

and PURCHLINE.PARTITION = INVENTDIM.PARTITION

LEFT JOIN ECORESCATEGORY on PURCHLINE.PROCUREMENTCATEGORY = ECORESCATEGORY.RECID

and PURCHLINE.PARTITION = ECORESCATEGORY.PARTITION

AND PURCHLINE.ITEMID = ''*/

 

while select itemid, purchId from purchLine

join inventDimId from inventdim

where inventDim.inventdimid == purchLine.inventDimId

join Recid from ecoResCategory

where ecoResCategory.RecId == purchLine.ProcurementCategory

join purchId from purchLine

where purchLine.purchId == PurchTable.purchId

//&& purchLine.itemid != ""

//&& inventDim.ItemId == itemId*/

 

 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: Joins in X++

    Hi,

    Please use the following code.

    static void PurchLine(Args _args)

    {

       PurchTable purchTable;

       PurchLine  purchLine;

       InventDim  inventdim;

       EcoResCategory ecoResCategory;

       while select purchTable

           join purchLine

           where purchLine.PurchId == purchTable.PurchId

           && purchLine.ItemId == ""

           join inventDimId from inventdim

           where inventdim.inventDimId == purchLine.InventDimId

           outer join Recid from ecoResCategory

           where ecoResCategory.RecId == purchLine.ProcurementCategory

       {

           info(strFmt("PurchId: %1, ItemId: %2", purchLine.PurchId, purchLine.ItemId));

       }

    }

    Thanks,

    Chaitanya Golla

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Joins in X++

    while select RecId from purchTable

    join itemid, purchId from purchLine

    where purchLine.PURCHID == purchTable.PURCHID

    && purchLine.ItemId == ''

    /*

    The following lines are implied by Ax, and therefor not needed

    && purchLine.DATAAREAID == purchTable.DATAAREAID

    && purchLine.PARTITION == purchTable.PARTITION

    */

     // In Ax the syntax 'outer join' is equal to a SQL 'Left outer join'.

    // for performance it's best to provide the join with a fieldlist, but if you don't Ax will return all fields of inventdim

    outer join inventdim

    where inventDim.inventdimid == purchLine.inventDimId

    /*

    The following line is implied by Ax, and therefor not needed

    && purchLine.PARTITION == inventdim.PARTITION

    /*

    outer join  ecoResCategory

    where ecoResCategory.RecId == purchLine.ProcurementCategory

    {

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans