Parameters in Traditional BQL Statements

If you need to specify values in a business query language (BQL) statement, you use BQL parameters, which are replaced with the needed values in the translation to SQL. For details, how BQL statements with parameters are translated to SQL, see Translation of a BQL Command with Parameters to an SQL Query Tree.

In this topic, you can find the description of the BQL parameters and the difference between them.

Current and Current2

The Current parameter, as well as the Current2 parameter, inserts the field value of the Current object from the PXCache object in the SQL query. If the Current object from the PXCache object is null, the Current parameter retrieves the default value of the field, while the Current2 parameter does not retrieve the default value and inserts null.

By using the Current or Current2 parameter in the declaration of a data view, you can refer to another view to relate these data views to each other. A typical example is referencing the current master record on master-detail forms. For details on how the Current and Current2 parameters are used, see To Relate Data Views to One Another.

Required

The Required parameter inserts a specific value into the SQL query.

By using the Required parameters, you can pass values to the SQL query, as described in To Pass a Field Value to the SQL Query and To Pass Multiple Field Values to the SQL Query.

Optional and Optional2

The Optional parameter works similarly to Current (as well as the Optional2 parameter works similarly to Current2) if you do not specify an explicit value for this parameter during BQL statement execution. However, you can also pass an explicit value of the parameter to the SQL query.

By using the Optional or Optional2 parameters, you can pass the external presentations of the values to the SQL query, as described in To Provide External Presentation of the Field Value to the SQL Query.

When a DAC includes more than one key field, you may need to use Optional<> in the primary data view of the graph. In this case, the primary data view typically filters the data records by all of the key fields except the last one. For example, you can select documents with the same document type as the current data record has and navigate through these documents with different document numbers. In the following example, the Document DAC has two key fields, DocType and DocNbr.

public PXSelect<Document,
        Where<Document.docType, Equal<Optional<Document.docType>>>> Receipts;
Optional<> could be replaced with Current<> in the code above unless you need to execute the Receipts data view in code to select a document with specific document type and number.
Note: If a data view contains the Optional<> and Required<> parameters, you should provide values for all Optional<> parameters that go before the Required<> parameters. For example, if you have the following operands in the query, the number of parameters is:
  • <Required<A>>.... <Optional<B>>... <Required<C>>: Always 3 parameters
  • <Required<A>>.... <Optional<B>>... <Required<C>>.... <Optional<D>>: At least 3 parameters
  • <Required<A>>....<Required<B>>.... <Optional<C>>: At least 2 parameters

Argument

The Argument parameter passes values from UI controls to the SQL query.

By using the Argument parameters, you can pass values to the data view delegates. For more information on how to use the Argument parameter, see To Pass a Value from a UI Control to a Data View.