Wednesday, 3 December 2014

Dynamic Query creation and execution

X++ code to create dynamic query :
EcoResProductTranslation   ecores;
    InventTable inventtable;
     Query query = new Query();
    QueryRun    qr;
    QueryBuildDataSource    invent,ecorestrans;
    //SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(EcoResProductTranslation), this);
    ecorestrans = query.addDataSource(tableNum(EcoResProductTranslation));
    invent  =   ecorestrans.addDataSource(tableNum(InventTable));
    invent.addLink(fieldNum(InventTable,Product),fieldNum(EcoResProductTranslation,Product));
    qr=new QueryRun(query);
    while(qr.next())
    {
        ecores = qr.get(tableNum(EcoResProductTranslation));
        inventtable = qr.get(tableNum(InventTable));
        info(strFmt("%1-%2",inventtable.ItemId,ecores.Name));
    }
    pause;

Below is the select query statement
EcoResProduct   ecores;
    EcoResProductTranslation    ecorestrans;
    InventTable inventtable;
    while select * from ecorestrans
    join *  from inventtable   where  inventtable.Product   ==  ecorestrans.Product
    {
       info(strFmt("%1-%2",inventtable.ItemId,ecorestrans.Name));
    } 

1 comment:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete