4.2. Evolution for Creating a Named Expression

Although named expressions can be far more complex than the example expression used in section 4.3., this expression can help demonstrate an evolution of and guidelines for more complex expressions.

The

Parts($pqty$=’7’&Parts.id=’id1’)

The above named expression calls for the same results as the demonstrated basic expressions for TADB List groups.

Return true for items that have 7 id1 parts in their Parts group.

The evolution is as follows:

  1. Type a basic expression.

Parts.quantity=’7’&Parts.id=’id1’

Parts.quantity='7'

The quantity in Parts is 7.

Parts.id='id1'

The ID in Parts is id1.

  1. Save time in typing.

Parts(quantity=’7’&id=’id1’)

Parts(quantity='7'......)

The quantity in Parts is 7.

Parts(......&id='id1')

The ID in Parts is id1.

This says exactly the same thing as above, but it is shorter and generates a different query internally.

The group Parts in the syntax is omitted from the internal sub-expression.  It has already been provided outside the parentheses.  

  1. Use a longhand version to move up to using a more complex named expression.

Parts(Parts.quantity=’7’&Parts.id=’id1’)

Parts(Parts.quantity='7'....)

The quantity in Parts is 7.

Parts(....&Parts.id='id1')

The ID in Parts is id1.

This executes the same way as the second example.

Warning: If the group outside the parentheses does not match the group inside the parentheses:

The expression will fail to parse and

An error will be generated.

However, the benefit of this permitted syntax is that Parts.quantity can be saved as a named expression Ptqy.

More information

4.4. Name expressions (Ptqy) inserted into expression.

4. Named Query expressions.