Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Converting SQL query to SysDa Query in X++

(0) ShareShare
ReportReport
Posted on by 12
Hi ,
 
Could someone please suggest how we can convert below SQL query to SysDa query.
 
select * from TAXTRANS_IN left join 
HSNCODETABLE_IN on TAXTRANS_IN.HSNCODETABLE = HSNCODETABLE_IN.RECID
left join 
SERVICEACCOUNTINGCODETABLE_IN on TAXTRANS_IN.SERVICEACCOUNTINGCODETABLE = SERVICEACCOUNTINGCODETABLE_IN.RECID
 
Thanks in advance.
  • Indra sena Profile Picture
    12 on at
    Converting SQL query to SysDa Query in X++
    Thanks for the reply Mohamed,
     
    I've created the query as you've specified and found that there is an issue in it.
     
    The second joinClause seems to be overwriting the previous joinclause , refer the below query string after executing it.
     
     
     FROM TaxTrans_IN 
     JOIN FROM ServiceAccountingCodeTable_IN 
     WHERE (TaxTrans_IN.ServiceAccountingCodeTable == ServiceAccountingCodeTable_IN.RecId)
     
    Could you suggest how we can overcome this ?
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    21,751 Super User 2025 Season 1 on at
    Converting sql query to SysDa Query in x++
    Hi,
     
    try this code :
            TAXTRANS_IN                         taxTans;
            HSNCODETABLE_IN                     hsnCodeTable;
            SERVICEACCOUNTINGCODETABLE_IN       serviceAccCodeTable;
    
            SysDaQueryObject qTaxTrans                       = new SysDaQueryObject(taxTans);
            SysDaQueryObject qHsnCodeTable                   = new SysDaQueryObject(hsnCodeTable);
            SysDaQueryObject qserviceAccCodeTable            = new SysDaQueryObject(serviceAccCodeTable);
    
            qHsnCodeTable.whereClause(new SysDaEqualsExpression
                                        (new SysDaFieldExpression(taxTans, fieldStr(TAXTRANS_IN, HSNCodeTable)),
                                         new SysDaFieldExpression(hsnCodeTable, fieldStr(HSNCODETABLE_IN, RecId))));
    
            qserviceAccCodeTable.whereClause(new SysDaEqualsExpression
                                        (new SysDaFieldExpression(taxTans, fieldStr(TAXTRANS_IN, ServiceAccountingCodeTable)),
                                         new SysDaFieldExpression(serviceAccCodeTable, fieldStr(SERVICEACCOUNTINGCODETABLE_IN, RecId))));
    
            qTaxTrans.joinClause(SysDaJoinKind::InnerJoin, qHsnCodeTable);
            qTaxTrans.joinClause(SysDaJoinKind::InnerJoin, qserviceAccCodeTable);
    Best regards,
    Mohamed Amine MAHMOUDI

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans