Wednesday, July 4, 2018

Queries

A query is an application object in the AOT. A query performs the same function
as the select statements. It is a better option because it allows for more flexible
user interaction when defining which records are to be retrieved. Queries provide
more flexibility, especially when sorting and specifying ranges.
The following figure shows an expanded query in the AOT:




With this example, the CustTable query has three data sources, two of which
have defined sorting and ranges. This section discusses methods within queries
and how to construct a simple query using X++.
Executing a Query in X++Queries can also be created and manipulated using X++. There are a number of
classes available that you can use to achieve this.
Two important classes when executing a query are:


Query()

QueryRun()
 
The Query() class does not "fetch" records, this is accomplished by using theQueryRun() class. The Query() class provides the framework for the query
whereas the
QueryRun() class starts this framework dynamically. The following
example creates and runs a simple query. The QueryStr() function validates that
the element of type Query called Cust exists in the AOT.



1
2
3
4
5
6
7
8
Query query = new Query (QueryStr(Cust));
// Use the query to build a queryRun object
QueryRun queryRun = new QueryRun (query);
// Traverse some records...
while (queryRun.next())
{
// ...
}

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...