Tuesday, July 10, 2018

Query Classes

Query classes were introduced in "Chapter 2: Working with Data." This lesson
provides a demonstration using these classes.
This example demonstrates how to use the Query classes to build a query.


1. Add a class to the AOT called
QueryClassDemo.

2. Add a class method called
createQueryRun().

3. Create a new
Query object.

4. Add a new datasource for CustTable using
Query.addDataSource().

5. Add a new range on CustTable.AccountNum using
QueryBuildDataSource.addRange().

6. Set a criteria on the range using
QueryBuildRange.value().

7. Make the query sort by CustTable.CustGroup, using
QueryBuildDataSource.addOrderByField().
 
8. Create a QueryRun object based on the query.

9. Return the QueryRun object.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public QueryRun createQueryRun()
{
  Query query;
  QueryRun qr;
  QueryBuildDataSource qbds;
  QueryBuildRange qbr;
  query = new Query();
  qbds = 
  query.addDataSource(TableNum(CustTable));
  qbr = qbds.addRange(FieldNum(CustTable, 
  AccountNum));
  qbr.value('4005');
  qbds.addOrderByField(FieldNum(CustTable, 
  CustGroup));
  qr = new QueryRun(query);
  return qr;
}

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...