Enter the key words to find the related topics

Dynamic query to fetch unique data.

I am using InventSite table to fetch unique SiteId and Name fields.


  1. Query                                              query;
  2. QueryBuildDataSource                   qbds;
  3. QueryRun                                         qr;
  4. InventSite                                         inventSite;
  5.  
  6. query      =  new Query();
  7. qbds       =  query.addDatasource(tablenum(InventSite));
  8. qbds.addGroupByField(fieldnum(InventSite, SiteId));
  9. qbds.addGroupByField(fieldnum(InventSite, Name));
  10.  
  11. while(qr.next())
  12. {
  13.         inventSite   =  qr.get(tablenum(InventSite));
  14.         info(strfmt("SiteId  : %1,  Name  : %2", inventSite.SiteId, inventSite.Name));
  15. }


Note: If I comment Step-9, in the result we wont get Name details

No comments:

Post a Comment