tips:revmedia:r107

INDEX_TOGGLE

Published ByDateVersionKnowledge LevelKeywords
Revelation Technologies23 APR 19922.1XINTERMEDIATESI.MFS, INDEX_TOGGLE, INDEXES, INDEXING, REBUILDING

Advanced Revelation 2.12 provides a subroutine, INDEX_TOGGLE, that you can use to temporarily remove indexing from a file. This is useful when you need to process a file but you don't need to use or maintain the indexes.

The syntax for INDEX_TOGGLE is:

INDEX_TOGGLE(FILE, HOLD, FLAG)

File is used to pass the name of the target file from which you want to suspend indexing.

Hold stores the information necessary to properly restore indexing.

Flag is passed with one of three values:

0Suspend indexing
1Restore indexing
2Restore indexing and rebuild indexes

Flag is returned null if the operation failed, true (1) otherwise.

Figure 1 shows the proper use of INDEX_TOGGLE.

INDEX_TOGGLE removes indexing only for the workstation that invokes it. All other workstations on the network continue to use and update indexes normally.

If you update indexed fields, you should not use INDEX_TOGGLE unless you are the only one on the network. You must also be sure to rebuild your indexes at the end of your process in order for them to be maintained. No index transactions are logged while the workstation has indexing turned off.

INDEX_TOGGLE removes SI.MFS from the file list maintained in memory, then reopens the file. You should always open (or re-open) your file after calling INDEX_TOGGLE to ensure that you get a valid file handle.

When restoring or rebuilding indexing, the subroutine does not check to see whether SI.MFS is already on the file. It assumes it is not there.

Remember that, once indexing is turned off for the workstation, all processes on the workstation will not have access to indexes for the file.

If your program crashes before you call INDEX_TOGGLE to restore the indexing, simply reattach the file. This safety mechanism means that you should not use INDEX_TOGGLE if the file will be reattached in the middle of processing.

Figure 1

DECLARE SUBROUTINE INDEX_TOGGLE

EQU OFF$    TO 0
EQU ON$     TO 1
EQU BUILD$  TO 2
EQU FALSE$  TO 0
EQU TRUE$   TO 1

TABLENAME = "SAMPLE_CUSTOMERS"
HOLD = ""

INDEX_TOGGLE(TABLENAME, HOLD, OFF$)
OPEN TABLENAME TO INPUTFILE ELSE
  FSMSG()
  INDEX_TOGGLE(TABLENAME, HOLD, ON$)
  STOP
END

SELECT INPUTFILE

DONE = FALSE$
LOOP
  READNEXT KEY ELSE
    DONE = TRUE$
  END
UNTIL DONE
  READ RECORD FROM INPUTFILE, KEY THEN
    /* Processing here */
  END
REPEAT

INDEX_TOGGLE(TABLENAME, HOLD, ON$)

/* If the processing updated indexed fields you would use this line instead
INDEX_TOGGLE(TABLENAME, HOLD, BUILD$)
*/
STOP
  • tips/revmedia/r107.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1