Correlatives

Correlatives

Top  Previous  Next

 

A correlative is an expression in field 8 of an A or S-type dictionary item that derives a value from data in a database record. Although similar in concept to the preferred I-type dictionary items, correlatives are less powerful and more difficult to maintain. They are provided in QM to aid migration of applications from other multivalue environments. New developments should use I-type items instead and it is recommended that correlatives should be converted to I-types as part of the migration process.

 

There are two styles of correlative:

 

A-correlatives are algebraic expressions and are relatively easy to understand.

 

F-correlatives are written in reverse Polish notation which makes them difficult for less experienced developers to understand.

 

The following additional items may be used in place of a correlative expression:

 

CALL nameCalls a catalogued QMBasic subroutine with a single argument which contains the field value (possibly multivalued) and should be updated by the subroutine. The @ACALL.FNO variable contains the field number from the dictionary record.

 

DIConverts an external format date to an internal day number.

 

convAn output conversion code. Applies the specified conversion code to the data.

 

Field 8 of the dictionary may be multi-valued. The first value must be one of the items listed above. The remaining values may be conversion codes or format codes to be applied to the result of the correlative. Format codes must be enclosed in either single or double quotes.

 

String operations in correlatives are normally performed in a case sensitive manner. The type code for an A or F-correlative can be followed by NOCASE; to select case insensitive string operations for this specific correlative. Alternatively, the CORRELATIVE.NOCASE mode of the OPTION command can be used to make all correlatives use case insensitive string operations.

 

On other multivalue databases, correlatives are processed interpretively and A-correlatives are translated into their equivalent F-correlative format at the start of a query for improved performance. On QM, correlatives are compiled in much the same way as I-type expressions so the potential minor performance advantage of writing an F-correlative directly is lost. The query processor will compile correlatives automatically when they are first used. The COMPILE.DICT (CD) command can be used to force a compilation.

 

 

Example

 

A;N(TEL)VM"L(3#) 3#-4#"

 

The above correlative takes the contents of the field named TEL and then applies a format mask to it.

 

 

A;NOCASE;N(CODE) = 'AX'

 

The above correlative tests whether the CODE field contains AX. The NOCASE prefix causes string comparisons to be case insensitive.