dfidx-create an index reference
Use this group of functions to create one or more index references to a subfile identified by an algorithm parameter. You can choose to index one or more paths.
Format
void dfidx_alg(dft_fil *file, dft_opt options,
dft_alg *alg);void dfidx_alg_pth(dft_fil *file, dft_opt options, dft_alg *alg,
dft_pth pth);
- alg
- is a pointer to an algorithm argument that identifies the subfile.
The TPFDF product uses the algorithm argument to determine the subfile (ordinal number) that is to be accessed. Specify the algorithm argument based on the type of algorithm that is defined in the DSECT or DBDEF macro for the file. If the DSECT or DBDEF macro defines the #TPFDB04 or the #TPFDB0D algorithm, do not use this parameter.
If the subfile you are accessing is contained in a detail file or intermediate index file defined with the #TPFDBFF algorithm, the TPFDF product uses the algorithm argument to locate the subfile. See TPFDF Database Administration for more information about how the TPFDF product uses the algorithm argument to locate the subfile.
- file
- is a pointer to the base address of the SW00SR slot (defined in c$sw00sr.h) of the file that you want to access and is returned by the dfopn function.
- options
- are the processing options for this function. Use one of the following values:
- DFIDX_PATH_ALL
- indexes all paths. Do not use this value when you specify the pth parameter.
- 0
- specifies that you do not want to use any processing options.
- pth
- is the path number for a detail subfile using index support. The value is defined in the DBDEF
macro and is a decimal number (0, 1, 2, and so on). The default path number is 0.
See TPFDF Database Administration for more information about path indexes.
Entry requirements
- You must have a detail file available.
- Ensure that the relationship of the index file (or index files, if there are multilevel indexes) to the detail file has been defined with the DBDEF macro by your database administrator.
Normal return
None.
Error return
See Identifying Return Indicators and Errors for information about how to check the error indicators.
Programming considerations
- Set the options parameter to zero if you do not require any processing options.
- The type definitions (for example, dft_fil, dft_ref, and dft_kyl) are defined in the c$cdfapi.h header file.
- The TPFDF product determines the amount of data to move in an index LREC by calculating the number of bytes between labels xxxxEyy and xxxxAyy in the DSECT for the index file, where xxxx is the first 4 characters in the name of the DSECT and yy is the primary key.
- Path 0 is the default path. The dfidx function creates index references for this path unless you have set one or more different paths using the dfopt function or specified the DFIDX_PATH_ALL value of the options parameter.
- No actual index structure needs to exist before you index the subfile. All that you need is an existing index file at the highest level of the index. This must be a fixed file. If there is no existing index structure, the TPFDF product creates the required index structure automatically when you call the dfidx function.
- If you index a subfile with the dfidx function in an application program, you must also remove the index when needed. (You can do this by using the dfdix function.)
- When running in detac mode, if an application program creates a pool file using the dfcre function and an index reference using the dfidx function, the application program must delete the index reference using the dfdix function before using the DFCLS_ABORT option on the dfcls function. If the index reference is not deleted, subsequent recoup processing may identify the index reference as a broken chain.
Examples
dft_fil *file_ptr;
char member_number[10];
·
·
·
dfidx_alg_pth(file_ptr, 0, member_number, 1);
