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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Query Classes

Hossein.K Profile Picture Hossein.K 6,648
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

Comments

*This post is locked for comments