The Classes That Compose BQL Statements

This topic contains an overview of the classes that you use to compose business query language (BQL) statements inside PXSelect and to define attributes of DACs.

Overview of the Classes

Almost all classes that compose BQL statements are derived from the IBqlCreator interface, which inherits from the IBqlVerifier interface. These interfaces provide the following key methods:
  • IBqlCreator.AppendExpression(): Used during a BQL command preparation to translate a BQL statement into an SQL tree expression, which is then produces the SQL text to be sent to the database maintenance server. For more information on how this method is used during BQL statement execution, see Translation of a BQL Command to SQL.
  • IBqlVerifier.Verify(): Used during the merge of the records with PXCache to evaluate a condition on a record retrieved from the database or calculate an expression with the record. For details on the merge, see Merge of the Records with PXCache.

Depending on the purpose of each BQL class, the class also implements the methods of the interfaces derived from the IBqlCreator interface. For example, the aggregation functions—such as Sum, Avg, Min, and Max—implement the methods of the IBqlFunction interface.

The high-level overview of BQL class inheritance is illustrated in the following diagram. For descriptions of the interfaces and classes, see the API Reference.
Figure 1. BQL commands


The sections below describe the classes derived from the BqlCommand class.

Select Classes

The Select classes, which are derived from the BqlCommand class, represent BQL commands and select all bound fields of the DAC and the unbound fields with specific attributes, such as PXDBCalced.
Note: More specific, the Select classes select all DAC fields that are decorated with the attributes that subscribe to the PXCommandPreparing event. For details on which fields are selected, see Translation of a BQL Command to SQL.

In a BQL expression based on Select, the first type parameter is a DAC, as shown in the following sample BQL statement.

Select<Product>

The Select classes can parse themselves into SQL and provide methods for modifying the BQL command. However, you cannot directly use the Select class to execute the BQL query. Typically, you use Select in attributes in DACs, such as the PXProjection attribute.

Search Classes

The Search classes, which are derived from the BqlCommand class, select one field of a DAC (while the Select classes select multiple fields).

In a Search-based statement, the first type parameter is a DAC field, as shown in the following sample BQL expression. This expression selects the Product.unitPrice field.

Search<Product.unitPrice>
These classes can parse themselves into SQL and provide methods for modifying the BQL command. However, you cannot directly use the Search class to execute the BQL query. Typically, you use Search in attributes in DACs, such as the PXSelector attribute. (PXSelectorAttribute requires a Search class and not a Select because the lookup control, which is configured by this attribute, displays precisely one field (usually a key field), which is what Search returns.)

BqlCommand Classes

The BqlCommand classes represent BQL commands. The system uses the following types of BqlCommand classes:

  • BqlCommand: This base class for the Select and Search classes is used by the system during the processing of data queries on the data entry forms.
  • BqlGenericCommand: This class, which is derived from the BqlCommand class, is used by the system during the processing of generic inquiries.
  • BqlSoapCommand: This class, which is derived from the BqlCommand class, is used by the system during the processing of reports. For details on report processing, see Display of Reports.

The main purpose of BqlCommand classes is to convert BQL commands to SQL text. The BqlGenericCommand and BqlSoapCommand classes provide additional methods for generic inquiry and report processing.