tips:revmedia:v2i1a5

Relational Indexes - Reordering

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 MAY 19901.15+EXPERTRELATIONAL, INDEX, REORDER, NO.PROTECT, SI

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.

  SUBROUTINE RELATIONAL_SORT(FILE, REC, FIELD)
  *  Author     AMcA
  *  Date  April 1990
  *  Purpose    To permit the reordering of rel mvs.
  *
    COMMON /%SI%/A,B,C,NO.PROTECT,E,F,G,H,I,J,K
    DECLARE FUNCTION POP.UP
    OPEN FILE TO SRC_FILE THEN
     READV DR FROM SRC_FILE, REC, FIELD THEN
      GOSUB REORDER
     END
    END
  RETURN

  REORDER:
    CONVERT @VM TO @FM IN DATA_RECORD
    MSG = "Please use the arrow keys and <Return> to"
    MSG := "|reorder, <F9> when finished"
    DR = POP.UP(0,0,"",DR,"","R","S",MSG,"","","","")
    IF DR THEN
     CONVERT @FM TO @VM IN DR
     NO.PROTECT = 1
     WRITEV DR ON SRC_FILE, RECORD, FIELD
    END
  RETURN

(Volume 2, Issue 1, Page 8)

  • tips/revmedia/v2i1a5.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1