In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

Relational Indexes - Reordering

In an effort to introduce some referential integrity into relational indexes, the ! code produced for a !file does not permit the modification of fields containing multivalued lists of related keys where those keys are maintained by a relational index on another file. Thus if an invoice file were relationally indexed via the customer number to an invoices field in the customer record, it would not be possible to amend these keys using a data entry window/editor on the customer record.

This makes sense but like all enforcing actions it can occasionally be a little annoying. This is especially the case when the user wants to periodically amend unsorted relational indexes to ensure that the most commonly used values appear at the top of the list. Or there may be a requirement to allow the user to update a relational index "from either end".

As the system is able to do this, (to update relational indexes in the first place) it follows that we must also be able. The key lies in an area of system labelled common called %%SI%% used for storing information for SI.MFS and the ! code. There are 11 variables associated with this area, being MAX.UPDATE.SIZE, INDEXES, INDEXES.FILEVAR, NO.PROTECT, OLD.REC, OLD.FLAG, OLD.FV, OLD.ID, DICT.FVS%, BATCH.MODE% and UPDATE.ITEM%. The variable that we wish to use is NO.PROTECT.

If NO.PROTECT is set to true before an attempt is made to write to a relationally indexed field, the write will be accepted and the update performed. The applications of this are many, but a simple application designed to allow the user to view the index values in a popup and reorder these values is given below.


0001    SUBROUTINE RELATIONAL_SORT(FILE, REC, FIELD)
0002    *  Author     AMcA
0003    *  Date  April 1990
0004    *  Purpose    To permit the reordering of rel mvs.
0005    *
0006      COMMON /%SI%/A,B,C,NO.PROTECT,E,F,G,H,I,J,K
0007      DECLARE FUNCTION POP.UP
0008      OPEN FILE TO SRC_FILE THEN
0009       READV DR FROM SRC_FILE, REC, FIELD THEN
0010        GOSUB REORDER
0011       END
0012      END
0013    RETURN
0014  
0015    REORDER:
0016      CONVERT @VM TO @FM IN DATA_RECORD
0017      MSG = "Please use the arrow keys and <Return> to"
0018      MSG := "|reorder, <F9> when finished"
0019      DR = POP.UP(0,0,"",DR,"","R","S",MSG,"","","","")
0020      IF DR THEN
0021       CONVERT @FM TO @VM IN DR
0022       NO.PROTECT = 1
0023       WRITEV DR ON SRC_FILE, RECORD, FIELD
0024      END
0025    RETURN

(Volume 2, Issue 1, Page 8)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel