bdfp1m14Programming Concepts and Reference

dfcpy-Copy a Subfile

Use this group of functions to copy a subfile. After processing the function, the TPFDF product closes the subfile and performs all subsequent actions on the copy.

Format

dft_hdr *dfcpy(dft_fil *file, dft_opt options);
dft_hdr *dfcpy_acc(dft_fil *file, dft_opt access, dft_opt options,
        dft_xxx acc);
dft_hdr *dfcpy_toa(dft_fil *file, dft_opt options, dft_fad toa);
dft_hdr *dfcpy_acc_toa(dft_fil *file, dft_opt access, dft_opt options,
        dft_xxx acc, dft_fad toa);
dft_hdr *dfcpy_acc_pth(dft_fil *file, dft_opt access, dft_opt options,
        dft_xxx acc, dft_pth pth);
dft_hdr *dfcpy_acc_toa_pth(dft_fil *file, dft_opt access, dft_opt options,
        dft_xxx acc, dft_fad toa, dft_pth pth);



acc
is an ordinal number, a file address, or a pointer to an algorithm string that specifies the subfile you want to access. The type for this parameter is determined by the value you specify for the access parameter.

access
is the method you want to use to access the subfile. Use one of the following values:

DFCPY_ALG
specifies that you are providing a pointer to an algorithm argument in the acc parameter. The acc parameter is of type dft_alg.

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.

DFCPY_FADDR
specifies that you are providing a file address in the acc parameter. A file address is in integer format. The acc parameter is of type dft_fad.

DFCPY_ORD
specifies that you are providing an ordinal number in the acc parameter. Ordinal numbers in a file start at zero and are in integer format. The acc parameter is of type dft_ord.

If the file is partitioned or interleaved, specify the relative ordinal number within the partition or interleave. If the file is not partitioned or interleaved, specify the file address compute program (FACE) ordinal number.

file
is a pointer to the base address of the SW00SR slot (defined in c$sw00sr.h) of the subfile that you want to access and is returned by the dfopn function.

options
are the processing options for this function. Use the following values:

DFCPY_CREATE
creates a new subfile using pool blocks.

DFCPY_HELD
specifies that the entry control block (ECB) is already holding the file address specified by the toa parameter. You can use this value only if you specify a toa 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.

toa
is an actual file address. The TPFDF product copies the subfile so that the prime block of the copy is at this address.

If used in a commit scope, the prime block specified by the toa parameter must be opened in the same commit scope as the subfile that is being copied. See Commit Scopes for more information about commit scopes.

Entry Requirements

None.

Normal Return

A pointer to the main storage address of the header of the prime block of the copy of the subfile.

Error Return

 See Identifying Return Indicators and Errors for information about how to check the error indicators. 

Programming Considerations

Examples

The following example copies a subfile to pool blocks. (The TPFDF product sets a pointer to the header in block_ptr.)

dft_fil *file_ptr;
dft_hdr *block_ptr;

  ·
  ·
  ·
block_ptr = dfcpy(file_ptr, 0);

Related Functions

dfrst-Restore a Subfile.