bdfp1m1oProgramming Concepts and Reference

dfsrt-Sort a Subfile

Use this function to sort logical records (LRECs) in an open subfile.

Format

void dfsrt(dft_fil *file, dft_fil *input, dft_opt options, dft_kyl *key_list);
void dfsrt_pty(dft_fil *file, dft_fil *input, dft_opt options,
     dft_kyl *key_list, dft_pty pty);



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.

input
is a pointer to the SW00SR slot of the subfile that you want to be sorted.

key_list
is the address of the key list specifying the order into which you want the TPFDF product to sort the LRECs. See Specifying Logical Records (LRECs) Using Keys for more information about key lists.

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

DFSRT_FULLFILE
sorts LRECs from the entire input file (specified in input), not from a single subfile.

DFSRT_RELEASE
releases the SW00SR slot of the input subfile (specified in input).

DFSRT_RELFC
releases the input subfile and deletes it from DASD. All overflow blocks are released. If the file is a pool file, the prime block is also released. If the file is a fixed file, the prime block is initialized to empty.

0
specifies that you do not want to use any processing options.

pty
is the pool type of the overflow blocks, which can be one of the following:

0
uses the pool type defined by the PF0 parameter of the DBDEF macro.

1
uses the pool type defined by the PF1 parameter of the DBDEF macro.

2
uses the pool type defined by the PF2 parameter of the DBDEF macro.

Entry Requirements

Both subfiles must be opened before you call the dfsrt function.

Normal Return

None.

Error Return

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

Programming Considerations

Examples

The following example sorts LRECs from the subfile file_ptr and puts them into the file out_file_ptr. The sort key is in a key list structure called keys.

/* set up the keys to use to sort the output file */
 
df_nbrkeys(&sortkeys, 1);
 
df_setkey(&sortkeys, 1, offsetof(struct gr95sr, gr95nam),
          member_size(struct gr95sr, gr95nam),
          0, NULL, 0, DF_UPORG, DF_CHAR);
 
/* set up the keys to use to select the LRECs in the input file */
 
df_setkey(&keys, 1, offsetof(struct gr95sr, gr95key),
          1, DF_EQ, &pky, 0, DF_UPORG, DF_CHAR);
 
 
df_nbrkeys(&keys, 1);
 
dfkey(in_fileptr, &keys);
 
/* sort the subfile after extracting matching LRECs            */
/* release the input file after the sort                       */
/* (the key list in the command is the sort key specification) */
 
dfsrt(out_file_ptr, in_fileptr, DFSRT_RELEASE, &sortkeys);

Related Functions

dfmrg-Merge Logical Records from Two Subfiles.