bdfp1m0f | Programming Concepts and Reference |
Applications normally perform all actions on the detail file, not on the index file, when they use basic indexing.
For example, to read an LREC from a detail file using the TPFDF macros and basic indexing:
DBOPN REF=GR25DF
DBRED REF=GR25DF,ALG==C'ADLER'
See TPFDF Database Administration for more information about basic indexing and the other forms of TPFDF index support.
An index LREC only points to the prime block of a subfile. The ALG parameter only defines the detail subfile that contains the LREC you require.
To locate a particular LREC in the subfile, you must also supply keys with the KEYn parameters or a key list. For example, to read an LREC with an LREC ID defined by equate #GR25K80 for passenger JONES, you can code:
DBRED REF=GR25DF,ALG==C'JONES',KEY1=(PKY=#GR25K80)
See Specifying Logical Records (LRECs) Using Keys for more information about keys.
Using basic indexing, you can add new LRECs to a detail file using the DBADD macro or dfadd function. Specify the index key as the algorithm argument. The TPFDF product inserts the LREC in the appropriate place in the detail file.
For example, to add a passenger named Jones to the passenger file, you can code:
DBADD REF=GR23DF,ALG==C'JONES',NEWLREC=EBW060
In this example, EBW060 contains the LREC to be added with information about passenger Jones.
If the detail subfile is organized UP or DOWN, specify KEYn parameters or a key list to place the LREC in an appropriate position in the detail subfile.
If the detail subfile does not exist, the TPFDF product will create the subfile and the index references automatically. For example, to create a detail subfile, the index references to that subfile, and add a passenger named Jones, you can code:
DBADD REF=GR23DF,INDEX,ALG==C'JONES',NEWLREC=EBW060
This has the same effect as the following sequence of macros:
DBCRE REF=GR23DF DBIDX REF=GR23DF,ALG==C'JONES' DBADD REF=GR23DF,NEWLREC=EBW060