logo
Powered by QM on a Rpi server
Home
About OpenQM
Sales and Downloads
Help and Support
About
Login

KnowledgeBase 00013: The CORRELATIVE.REUSE Option

Last updated: 22 Jul 2016
Applies to: All versions
Search  
Top level index       Full Index Search Tips
Previous article     Next article

Background

The CORRELATIVE.REUSE setting of the OPTION command was added at release 2.9-7 as a way to improve compatibility of correlatives with Pick systems. Part of the reason for needing this option is that QM executes correlatives in a different way from Pick systems.

The precise behaviour of correlatives is not very well documented in any of the multivalue systems. QM's behaviour was based on information extracted from documentation for PI/open, UniVerse, D3, mvBase and several training packages from Malcolm Bull.

There is frequent reference in these documents to the use of the R qualifier after a data item to imply an operation equivalent to use of the REUSE() function in QMBasic. Using an F-correlative as our example, we might have something like

   F;'~';1;: 
to prefix the content of field 1 with a tilde. This is equivalent to use of a QMBasic expression
   CATS('~', @RECORD<1>) 

But, what if field 1 is multivalued? According to many of the multivalue correlative documents, we must amend our correlative to be

   F;'~'R;1;: 
which is equivalent to
   CATS(REUSE('~'), @RECORD<1>) 

So far, all is ok. Now let's say that we want our correlative to return the record id (which is always single valued) followed by a tilde and then the content of multivalued field 1. It looks as though we need to write

   F;0;'~';1 
but we somehow need to insert an R option that will be applied to the result of the first concatenation. The language doesn't have a way to do this.

The underlying problem may be that QM converts correlatives to the equivalent multivalued functions of QMBasic rather than executing the correlative multiple times, once for each value in the multivalued data, which is what Pick appears to do. In most cases, there is no difference between these two approaches.

This leads to a question... What does the R option actually do in Pick? If the expression is evaluated many times, it doesn't appear to be needed


The Solution

Enabling the CORRELATIVE.REUSE mode of the OPTION command causes all correlative operators to behave as though the R option was present, even those like our double concatenation where there is nowhere in the expression syntax to insert the R.

QM has never guaranteed 100% compatibility with Pick or any other system but we aim to make migration easy. This is the first time that this incompatibility has been observed in several years of users migrating to QM from Pick style systems.

Rather than making this behaviour standard we chose to make it an option just in case there is some situation where it would have undesireable effects.


Related Articles

None.



Please tell us if this article was helpful
Very     Slightly     Not at all
Comments
Email (optional)