Monday, March 22, 2021

 The main techniques for selecting records in the database are as follows:

  • The select statement
  • A query

The techniques are essentially the same. They both deliver a set of records from the database in a table variable that can be accessed.

Use the select statement when:

  • The selection criteria are complex.
  • You are selecting a set of records from X++. The user is not going to change the selection criteria.

Use a query when:

  • The user can choose which records are selected.
  • The user can change the range of records to be selected.
  • The selection criteria are not more complex than the query can accommodate.
  • When you use queries, develop them in the Application Object Tree (AOT) or build them from scratch in your code. In both situations, the query can be modified in the code. A query built from scratch in code can be saved so that it occurs in the AOT. However, this should usually be avoided.

Build a query in the AOT when:

  • A specific query definition is being used in many places. (The query in the AOT can be reused.)
  • The query must contain code.
  • The query definition is more complex. The AOT provides a visual representation of the query.

No comments:

Post a Comment