Appendix J (Isam Considerations). DORIC 9.65, INFO-Text software
विज्ञापन
विज्ञापन
Appendix J
ISAM Considerations
Special considerations apply when using ISAM (Indexed
Sequential Access Method) files with INFO. The creation and maintenance of the link to an ISAM file requires special care and effort. You should consider using ISAM files with INFO when circumstances such as these exist: n
You want to access an existing ISAM file.
n
An application requires that multiple users have write access to the file at the same time.
n
Records are added to the file frequently and must be maintained in sequential order.
n
An application requires that records in a large file be accessed quickly by key.
Before reading this chapter, you should be familiar with the relevant ISAM utilities and those INFO commands that reference ISAM files or provide ISAM capability: ALTER,
DEFINE, DIRECTORY, EXTERNAL, FILES, ITEMS,
LIMIT, NEWMAP, PURGE, REDEFINE, RELATE,
RESELECT, SELECT, and SET.
This chapter provides separate discussions about creating the link between INFO and an ISAM file and maintaining the ISAM link once it is established.
Creating the INFO and ISAM Link.
Before you can establish a link between INFO and an
ISAM file, the file must be defined both to the operating system and to INFO. The order in which you do this is not important. You can define the file to INFO before you create the ISAM file under the operating system, or vice versa.
The instructions first describe how to define an ISAM file to INFO and then explain how to create the link between
INFO and the ISAM file at the operating system.
INFO Reference Manual Appendices A-81
ISAM Considerations
Appendix J
Defining the ISAM file to INFO.
To define the ISAM file to INFO, use the DEFINE command. You must know the data type of each field in the ISAM file. Remember that the ISAM file does not have to exist before you define the file to INFO, but you must ensure that the INFO definition of the file matches the actual file before you can create the link from INFO to the file.
After you define the file, use the ALTER command to define the ISAM key fields. The dialog on the next page shows the command sequence used to alter the item
PRIMARY.KEY in ISAM. EXAMPLE to be a primary key, and data item SECONDARY.KEY to be a secondary key.
Sample ALTER Dialog to Create ISAM keys.
ENTER COMMAND >ITEMS LONG
DATAFILE NAME: ISAM-DF
5 ITEMS: STARTING IN POSITION 1
COL ITEM NAME WDTH OPUT TYP N.DEC PROT KEY OCCRS INDX CNLV CC CN UN
1 PRIMARY.KEY 3 3 C - 4 - - - - - - -
4 SECONDARY.KEY 2 2 C - 4 - - - - - - -
6 DATA1 10 10 C - 4 - - - - - - -
16 DATA2 10 10 C - 4 - - - - - - -
26 SPARES 15 15 C - 4 - - - - - - -
ENTER COMMAND >ALTER PRIMARY KEY
1 PRIMARY.KEY 3 3 C - 4 - - - - - - -
ITEM NAME><R>
ALTERNATE NAME ><R>
ITEM OUTPUT WIDTH ><R>
ITEM TYPE ><R>
ITEM PROT. LEVEL ><R>
ENTER KEY LEVEL >0
ENTER INDEX NUMBER ><R>
1 PRIMARY.KEY 3 3 C - 4 - - - - - - -
A-82 Appendices INFO Reference Manual
Appendix J
ISAM Considerations
ENTER COMMAND >ALTER SECONDARY.KEY
4 SECONDARY.KEY 2 2 I - 4 - - - - - - -
ITEM NAME ><R>
ALTERNATE ITEM NAME ><R>
ITEM OUTPUT WIDTH ><R>
ITEM TYPE ><R>
ITEM PROT. LEVEL ><R>
ENTER KEY LEVEL >1
ENTER INDEX NUMBERS ><R>
4 SECONDARY.KEY 2 2 C - 4 D1 - - - - - -
ENTER COMMAND >ITEMS LONG
DATAFILE NAME: ISAM - DF
5 ITEMS: STARTING IN POSITION 1
COL ITEM NAME WDTH OPUT TYP N.DEC PROT KEY OCCRS INDX CNLV CC CN UN
1 PRIMARY.KEY 3 3 C - 4 O - - - - - -
4 SECONDARY.KEY 2 2 I - 4 D1 - - - - - -
6 DATA1 10 10 C - 4 - - - - - - -
16 DATA2 10 10 C - 4 - - - - - - -
26 SPARES 15 15 C - 4 - - - - - - eg.
Linking to an existing ISAM file.
If the ISAM file already exists at the operating system, the
INFO file template may be linked to this by use of the
EXTERNAL command.
ENTER COMMAND >SEL ISAM-DF
O RECORD(S) SELECTED
ENTER COMMAND >EXTERNAL
ENTER COMPLETE FILE NAME OF EXTERNAL FILE
pathname/filename
DATABASE (C/R FOR DEFAULT, LIST FOR OPTIONS)
CI (Unix) OR XI (VMS and Primos)
ENTER COMMAND >SEL ISAM-DF NEWMAP
^ RECORD(S) SELECTED
INFO Reference Manual Appendices A-83
ISAM Considerations
Appendix J
Creating an ISAM file at the operating system.
If the ISAM file does not already exist at the operating system level, it is possible to create an empty ISAM template using the INFO file template. The procedure varies according to the operating system.
UNIX
ENTER COMMAND >SEL ISAM-DF
O RECORD(S) SELECTED
ENTER COMMAND >EXTERNAL
ENTER COMPLETE FILE NAME OF EXTERNAL FILE pathname/isam-df
DATABASE (C/R FOR DEFAULT, LIST FOR OPTIONS)>CI
ENTER COMMAND >SEL ISAM-DF (or REL ISAM-DF BY KEY)
O RECORD(S) SELECTED
At this point, two files will have been created in the directory specified in the external pathname (or in the local directory if no pathname was specified): isam-df.idx
isam-df.dat
Note: The ISAM filename at Unix level can have a maximum of 10 characters before the extension; this is a limitation of the C-ISAM file system.
VMS
ENTER COMMAND >SEL ISAM-DF
O RECORD(S) SELECTED
ENTER COMMAND >EXTERNAL
ENTER COMPLETE FILENAME OF EXTERNAL FILE
[pathname]ISAM-DF.ISM
DATABASE (C/R FOR DEFAULT, LIST FOR OPTIONS)>XI
ENTER COMMAND >SEL ISAM-DF (or REL ISAM-DF BY KEY)
CREATING NEW ISAM FILE. OKAY? (Y/N).Y
O RECORD(S) SELECTED
A-84 Appendices INFO Reference Manual
Appendix J
ISAM Considerations
At this point, one file will have been created in the directory specified in the external pathname (or in the local directory if no pathname was specified):
ISAM-DF.ISM
N.B The VMS ISAM template will have been created with most parameters set to their default values. If it is required to alter any of these, use the EDIT/FDL utility.
See the appropriate VMS documentation for details.
INFO does not support the following RMS ISAM options: n
Segmented keys. Corresponding key items in the ISAM file and the INFO file template must match exactly.
n
Individual keys that are greater than 64 bytes in length n
Variable length records.
Primos
ENTER COMMAND >SEL ISAM-DF
O RECORD(S) SELECTED
ENTER COMMAND >MIDAS treename filename
*** MIDAS FILE BUILD COMPLETE - FILE NOW BEING
SELECTED! ***
O RECORD(S) SELECTED
At this point one file will have been created in the directory specified in the treename argument in the MIDAS command with the specified filename; if neither argument was supplied, INFO will have created an empty MIDAS template in the local directory with the same name as the
INFO file template, i.e. ISAM-DF
Maintaining the ISAM link.
Once the link from INFO to an ISAM file has been established, you can begin to access the file from INFO.
The first time you select the ISAM file , INFO creates a file of primary key values, called a bitmap. For more information about bitmap files, see APPENDIX F, INFO
INFO Reference Manual Appendices A-85
ISAM Considerations
Appendix J
Internal Files. INFO uses the bitmap to access the file, as described below.
When you issue a SORT command on an ISAM file, INFO reorders your bitmap according to the SORT criteria. It does not change the organisation of the ISAM file itself.
When you access records in an ISAM file by key items, you can create record sets. More information about how to do this is provided below.
You can add records to an ISAM file through INFO, using the ADD command or an input form or with RELATE FILL.
When you select or relate an ISAM file that you only want to read, such as with REPORT or match processing in an input form, you should always use the RO (read-only) option with the command.
ISAM file records may become locked during processing when another user is using a record when you request it.
INFO provides the system variables $LOCK0 through
$LOCK9 and $LOCK-QUESTION to allow you to control whether or not INFO attempts again to access a locked record. See Appendix D, System Items for a detailed discussion of these system items.
The rest of this discussion provides details of bitmap, set, and related files processing, and information about using
ISAM files in INFO programs.
Bitmap Processing.
As stated above, when you first select an ISAM file, INFO builds a bitmap containing an entry for each record in the file. This bitmap is created for your sign-on user name.
Each time you select the file subsequently, you can only access those records that have entries in you bitmap for the file. You are responsible for maintaining your copy of the bitmap, as described below.
A-86 Appendices INFO Reference Manual
Appendix J
ISAM Considerations
When records are added, modified, or deleted from the file, the following conditions determine whether or not your bitmap is updated to reflect the changes: n
If you add records using the ADD command or an input form, or delete records from the file using the PURGE command, INFO updates your bitmap to reflect the added or deleted records. Be aware that other INFO users may be modifying the same file concurrently. In that case, you must recreate you bitmap following the completion of all updating so that it reflects all changes made to the file.
n
If you change key data items, INFO deletes the record and adds a new record with the new key data value. Your bitmap is updated to reflect the change.
n
When you use an UPDATE BY command that specifies a key field, INFO ignores your bitmap and updates the file directly. You can use this command to bypass bitmap processing when you need to update records quickly.
n
If another INFO user, or program outside of INFO adds or deletes records from, your bitmap does not reflect these changes until you recreate your bitmap.
To recreate your bitmap for an ISAM file, you can use the
SELECT, or NEWMAP commands. See the discussion of each command, in this manual, for detailed information about how each command causes the bitmap to be recreated, then decide which method is most appropriate for your processing circumstances.
Please note that in most circumstances, it is more efficient to SELECT an ISAM file with the DYNAMIC option rather than with NEWMAP: this is because the NEWMAP option will direct INFO to immediately make a complete pass through the ISAM file and build a new bitmap, whereas the
DYNAMIC option will cause the bitmap to be created as the file is processed.
Set Processing
When you select a file, INFO includes each record in the file in your selected record set. This initial selected set is
INFO Reference Manual Appendices A-87
ISAM Considerations
Appendix J
called SET 1 for the file. You can establish up to 16 sets for the file, as described below. Each set represents an alternative bitmap that reflects different selection criteria for records in the file. When you establish a set, INFO displays the number assigned to the set. Set numbers are assigned in sequential order (Set 2, then Set 3, and so on).
The current set number is held in the System Item
$MSET.
Each time you specify a primary or secondary ISAM key item in a RESELECT BY command, INFO processes the entire ISAM file. Subsequent RESELECT BY commands with different selection criteria create alternative sets of records.
To return to a previously selected set of records, specify the desired set number in a SET command request. If you select another file during the RESELECT BY command sequence, the sets that you have established are unavailable until you select the ISAM file again. INFO maintains a record of the sets created so that you can reference them again the next time you select the ISAM file. Any time you recreate your bitmap, however, INFO deletes any existing sets for the file.
Relating File Processing.
After you select an ISAM file, you can relate other INFO datafiles to it by any data item in the file. If you want to relate to an ISAM file, you must relate by a key field and specify either no options, the FILL or TABLE options, or the RO (read-only) option. You cannot use any other
RELATE options when relating an ISAM file.
When you relate an ISAM file, INFO ignores the bitmap and accesses all the records in the ISAM file directory.
When you specify the FILL option, you can only add a record if its key field data does not already exist in the file; if it does, INFO will position to that related ISAM record.
Using ISAM Files in Programs.
When you access an ISAM file in an INFO program, minimize the number of write requests to the file. To do this, you should perform any MOVE or CALCULATE logic to ISAM file records in an even-numbered program section. INFO writes each record only once at the end of
A-88 Appendices INFO Reference Manual
`
Appendix J
$NOSEL
$SETMAX
$SETMIN
ISAM Considerations
an even-numbered section, regardless of the number of
MOVE and CALCULATE commands executed on the record in the section. If you move or calculate to ISAM records in an odd-numbered program section, INFO writes each record in the datafile for each command. That is,
INFO makes a complete pass through the file for each command.
System Items
The following System Items behave differently when used in conjunction with ISAM files: if the ISAM file is selected with the DYNAMIC option,
$NOSEL is initially set to 0, and is incremented as records are read.
if the ISAM file is processed by the LIMIT command, INFO will read the file until it either finds a record that matches the condition or reaches end of file; if the former, $NOSEL is set to 1 and incremented when any other records meeting the LIMIT condition are read by the next active command; if the latter, $NOSEL is set to 0.
as for $NOSEL always set to 1 when ISAM file is selected DYNAMIC or
NEWMAP or processed by the LIMIT command.
INFO Reference Manual Appendices A-89
डाउनलोड
विज्ञापन