dfdel-delete one or more logical records

Use this group of functions to delete:
  • One or more logical records (LRECs) from an open subfile
  • The LRECs in one or more subfiles of a file
  • A complete extended LREC
  • All of the LRECs in a file
  • Some or all of the subfiles referenced from the LRECs that you delete
  • One or more subLRECs in an extended LREC.

Format

dft_rec *dfdel(dft_fil *file, dft_opt options); dft_rec *dfdel_acc(dft_fil *file, dft_opt access, dft_opt options, dft_xxxacc);
dft_rec *dfdel_lst(dft_fil *file, dft_opt list_type, dft_opt options,
        dft_idl *lst);
dft_rec *dfdel_nbr(dft_fil *file, dft_opt nbr_type, dft_opt options,
        dft_xxxnbr);
dft_rec *dfdel_acc_lst(dft_fil *file, dft_opt list_type, dft_opt access,
        dft_opt options, dft_xxxacc, dft_idl *lst);
dft_rec *dfdel_acc_nbr(dft_fil *file, dft_opt nbr_type, dft_opt access,
        dft_opt options, dft_xxxacc, dft_xxxnbr);
dft_rec *dfdel_lst_nbr(dft_fil *file, dft_opt list_type, dft_opt nbr_type,
        dft_opt options, dft_idl *lst, dft_xxxnbr);
dft_rec *dfdel_acc_lst_nbr(dft_fil *file, dft_opt list_type,
        dft_opt nbr_type, dft_opt access, dft_opt options,
        dft_xxxacc, dft_idl *lst, dft_xxxnbr);
dft_rec *dfdel_sub(dft_fil *file, dft_opt options,
        dft_sno sub, dft_qty qty);
Access Parameter Values:
Read syntax diagramSkip visual syntax diagram DFDEL_ALGDFDEL_FADDRDFDEL_FADDR8DFDEL_ORD
List_Type Parameter Values:
Read syntax diagramSkip visual syntax diagram DFDEL_INCLUDEDFDEL_EXCLUDE
Nbr_Type Parameter Values:
Read syntax diagramSkip visual syntax diagram DFDEL_LISTDFDEL_LRECNBR
Options Parameter Values
Read syntax diagramSkip visual syntax diagram|DFDEL_ALLDFDEL_ALL_DOWNWARDDFDEL_ALL_UPWARDDFDEL_BEGINDFDEL_EMPTYCHECKDFDEL_FULLFILEDFDEL_INITIALIZEDFDEL_LASTDFDEL_NEXTDFDEL_NODUMPDFDEL_NOEMPTYCHECKDFDEL_NOKEY0
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 dfifb or dfopn function. Use the acc parameter to specify a particular subfile to access. If you do not specify the acc parameter, the last subfile accessed with this SW00SR slot will be accessed.
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:
DFDEL_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.

DFDEL_FADDR
specifies that you are providing a 4-byte file address for the acc parameter. A file address is in integer format. The acc parameter is of type dft_fad.
DFDEL_FADDR8
specifies that you are providing a pointer to an 8-byte file address for the acc parameter. The acc parameter is of type * dft_fad8.
DFDEL_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.

list_type
specifies which files to delete. Use one of the following values:
DFDEL_INCLUDE
deletes only the files listed in the structure pointed to by the lst parameter. This is the default value.
DFDEL_EXCLUDE
deletes all files except those listed in the structure pointed to by the lst parameter.
lst
is a pointer to a list of up to 10 subfiles to be included or excluded in the delete action when the DFDEL_INCLUDE or DFDEL_EXCLUDE value of the list_type parameter is specified.

The lst parameter is provided so that you can delete, or not delete, subfiles that are referenced from the LREC that you are deleting.

To delete LRECs in all the referenced subfiles, specify zero as the number of file identifiers and provide one file identifier consisting of a string of 2 space characters. For example:

struct id_list include_all = {0,{{' ',' '}}};
nbr
is an LREC number (type dft_nbr) or a pointer to a list (type dft_rcl) of LRECs to be deleted. The following is deleted based on the value of the nbr_type parameter:
  • A single LREC specified by nbr if the nbr_type parameter is set to DFDEL_LRECNBR.
  • All the LRECs in a list pointed to by nbr if the nbr_type parameter is set to DFDEL_LIST.

    Specify the LRECs in this list as character array. For example:

    char nbrs[10] = "2/3-6/LAST";

    The list contains one or more LREC sequence numbers separated by a slash (/). You also can specify a range of sequence numbers by separating the beginning and end of the range by a hyphen (-). You can use LAST to mean the last LREC of the subfile and ALL to mean all the remaining LRECs. You also can end the list with a nonnumeric character.

    Note:
    • The ranges must be in ascending order; if one is found out of order, that range and all subsequent ranges are ignored.

      For example, if there are 41 LRECs in a subfile, all of the following lists have the same effect:

      20/31/32/33/37/38/39/40/41
      20/31/32/33/37-41
      20/31-33/37-LAST
      20/31-33/37/ALL
    • You cannot specify the value zero in the list of LREC numbers.
Note:
  • If you use the #TPFDB0D algorithm, you must specify a specific LREC number for the value of nbr.
  • LRECs are numbered in increasing order from the start of the subfile (the first LREC in the prime block has sequence number 1).
  • If you specify this parameter with active keys, only those LRECs that match the key conditions are included in the sequence numbering; LRECs that do not match are ignored.
  • In functions that do not include the nbr_type parameter, the value of nbr is a specific LREC number.
nbr_type
specifies the type of value that you are providing in the nbr parameter. Use one of the following values:
DFDEL_LIST
specifies that you are providing a pointer to a list of LREC numbers (type dft_rcl).
DFDEL_LRECNBR
specifies that you are providing the sequence number of a single LREC (type dft_nbr).
options
are the processing options for this function. Use the following values:
DFDEL_ALL
deletes every LREC in the open subfile that you have specified. If you currently have keys active, the function deletes only the LRECs that match the keys.

If you delete all the LRECs from a fixed file using the DFDEL_NOKEY option or with no keys active, the function writes the empty prime block to DASD after deleting the LRECs (the block header and optional trailer are not deleted). Any blocks previously chained to the prime block are released.

If you delete all the LRECs from a pool subfile using the DFDEL_NOKEY option or with no keys active, the dfdel function releases the overflow blocks and marks the prime block for release during close processing. See dfcls-Close a Subfile for information about the DFCLS_RELFC option for processing details. Note that if you delete all the LRECs from a pool subfile and add an LREC before you close the subfile, the prime block is no longer marked for release.

For B+Tree files, if no keys are specified, DFDEL_ALL releases the index blocks as well as the data blocks.

If the subfile was opened in detac mode, you cannot recover the subfile using the dfcls function with DFCLS_ABORT.

If you combine this value with a lst parameter, the TPFDF product deletes only the LRECs in the lst parameter.

If you specify keys in addition to DFDEL_ALL, this function deletes all the LRECs in the open subfile that match these keys. If you also specify the DFDEL_FULLFILE value, the dfdel function deletes all the LRECs that match the keys in an entire file. In this case, the blocks are not released, whether they are fixed or pool, because some LRECs can remain in a file after deletion.

You can use the DFDEL_ALG value on the access parameter with the DFDEL_ALL value to delete LRECs from an indexed detail file. The DBDEL macro deletes the index entry for the subfile and releases the indexed subfile if it is in pool.

DFDEL_ALL_DOWNWARD
deletes all LRECs from (and including) the current LREC to the last LREC in the subfile. If you currently have keys active, the function deletes only the LRECs that match the keys.
DFDEL_ALL_UPWARD
deletes all LRECs from (but not including) the current LREC to the first LREC in the subfile. If you currently have keys active, the function deletes only the LRECs that match the keys.
DFDEL_BEGIN
specifies that you want to start at the beginning of the file when searching for LRECs to delete.
DFDEL_EMPTYCHECK
specifies that dfdel processing checks the subfile to determine that it is empty, regardless of what the database definition (DBDEF) macro has set as the default with the EMPTYCHECK parameter. If specified, SW00RT2 #BIT5 is set to 0 if the subfile is not empty and set to 1 if it is empty. See TPFDF Database Administration for more information about the DBDEF EMPTYCHECK parameter.
DFDEL_FULLFILE
deletes an LREC from every subfile of the file.

If you combine this value with the DFDEL_ALL value, the function deletes every LREC in every subfile of the file. You can delete LRECs in certain subfiles only by specifying the beg and end parameters with the dfadr function.

DFDEL_INITIALIZE
empties the entire subfile apart from the standard TPFDF header in the prime block. It releases any blocks previously chained to the prime block.
DFDEL_LAST
deletes the last LREC of the subfile. (If you have set keys, the function only deletes LRECs with matching keys.)
DFDEL_NEXT
deletes the next LREC in sequence from a file. (If you have set keys, the function only deletes LRECs with matching keys.)
DFDEL_NODUMP
specifies that you do not want the TPFDF product to issue any of the following system errors while processing this function:
  • DB0100
  • DB0102
  • DB0117
  • DB0123
  • DB0138
  • DB0140.

See TPFDF Messages (System Error, Online, Offline) for more information about these system errors.

Note: Using the DFDEL_NODUMP value is not recommended because it can prevent system errors from being issued that indicate a critical problem.
DFDEL_NOEMPTYCHECK
specifies that dfdel processing does not check the subfile to determine that it is empty, regardless of what the database definition (DBDEF) macro has set as the default with the EMPTYCHECK parameter. See TPFDF Database Administration for more information about the DBDEF EMPTYCHECK parameter.
DFDEL_NOKEY
deactivates any currently active keys.
Note:
  • If the file is not open when you specify the DFDEL_NOKEY value, the dfdel function opens the file and deletes the first LREC.
  • If the file is open when you specify the DFDEL_NOKEY value, the dfdel function deletes the current LREC.
0
specifies that you do not want to use any processing options.
qty
is the number of subLRECs you want to delete.
sub
is the sequence number of the first subLREC in the extended LREC that you want to delete.

Entry requirements

Before using the dfdel_sub function, you must use a dfred function to locate the extended LREC from which you want to delete the subLREC.

Normal return

  • One of the following:
    • Pointer to the next LREC in the subfile (after the last deleted LREC)
    • Pointer to the current extended LREC from which the subLREC or subLRECs were deleted.
  • After you use the DFDEL_ALL_DOWNWARD or DFDEL_ALL_UPWARD value, the SW00REC is set to zero and the SW00RTN is set to X'40'.

Error return

  • See Identifying Return Indicators and Errors for information about how to check the error indicators.
  • A pointer to protected main storage for all functions except the dfdel_sub function.
  • For the dfdel_sub function, there is no error return when the subLRECs that you specify to be deleted do not exist. In all cases, the return value is as if the function was processed successfully.

Programming considerations

  • The type definitions (for example, dft_fil, dft_ref, and dft_kyl) are defined in the c$cdfapi.h header file.
  • Some parameters can be of different types based on the value you specify for that parameter or a related parameter. In the function format, the type of these parameters is shown as dft_xxx. See the description of the specific parameter for information about what type definition to use for that parameter.
  • After opening a file, if you use fullfile processing to access or update records, you must continue to use fullfile processing on any subsequent functions when available until the file is closed. Accessing or updating subfiles using fullfile processing cannot be mixed with functions that access or update records without using fullfile processing.
  • If you call the dfcls function with an options value of DFCLS_RELFC, you do not have to call a dfdel function. In this case, the dfcls function does an internal delete.
  • If you specify the DFDEL_FULLFILE value and the end-of-file indicator is set, you cannot call additional TPFDF functions until the file is closed. However, you can specify the DFCLS_REUSE value on the dfcls function. See Identifying Return Indicators and Errors for information about the end-of-file indicator.
  • If you do not specify any optional parameters and a current LREC (usually the last LREC read) has been located, the dfdel function deletes the current LREC. Any previously specified keys are ignored.

    If you do not specify any optional parameters and a current LREC has not been located, the dfdel function result cannot be predicted.

  • Any active keys are ignored when you use the #TPFDB0D algorithm.
  • If you specify the DFDEL_ALL and DFDEL_NOKEY values for a B+Tree file, the dfdel function will pack the file.
  • Before you use the DFDEL_ALL_DOWNWARD or DFDEL_ALL_UPWARD value, first establish a current LREC (for example, using the dfred function).
    Attention: Using the DFDEL_ALL_DOWNWARD or the DFDEL_ALL_UPWARD value can cause the values that were created previously for the dfret function to be corrupted.
  • If the released subfiles contain LRECs that reference other subfiles, you can use the INCLUDE or EXCLUDE parameters to specify that the DBDEL macro should also release these referenced subfiles. This process is repeated for all forward paths defined in the DBDEF macro. The referenced subfiles are not de-indexed automatically, even when AUTODEINDEX=YES is specified on the DBDEF macro for the referenced file.
  • If you do not specify the lst parameter (a pointer to a list of subfiles), subfiles that are referenced from the LREC for deletion will not be released.

Examples

  • The following example deletes all LRECs in a subfile.
    dft_fil *file_ptr;
    
    
      ·
    
      ·
    
      ·
    
    (void) dfdel(file_ptr, DFDEL_ALL);
  • The following example deletes five subLRECs, starting at the first (subLREC number 0):
    dft_fil *file_ptr;
    
    
      ·
    
      ·
    
      ·
    
    dfdel_sub(file_ptr, 0, 0, 5);
  • You can delete a number of subLRECs without starting at the first. To delete n subLRECs from the mth subLREC onward, specify:
    dft_fil *file_ptr;
    
    
      ·
    
      ·
    
      ·
    
    dfdel_sub(file_ptr, 0, m-1, n);

    (The first subLREC in an extended LREC is numbered zero so the mth subLREC is numbered m-1.)

  • To delete all the subLRECs from the mth to the last in the LREC, specify:
    dft_fil *file_ptr;
    
    
      ·
    
      ·
    
      ·
    
    dfdel_sub(file_ptr, 0, m-1, 99);

    (The previous example assumes there is a maximum of 99 subLRECs after the mth subLREC.)

  • Suppose an extended LREC contains six subLRECs. You could delete the two middle subLRECs (numbers 2 and 3) by specifying:
    dft_fil *file_ptr;
    
    
      ·
    
      ·
    
      ·
    
    dfdel_sub(file_ptr, 0, 2, 2);
  • The following example will delete all the LRECs (matching any default or read keys set) in the subfile pointed to by dr21_ptr and all referenced subfiles in the deleted LRECs with record IDs of X'B222' and X'B226':
    static dft_fil *dr21_ptr   = NULL; 
    int ord = 0; 
    struct id_list include_all = {2,{ 
                                      {'\xB2','\x22'}, 
                                      {'\xB2','\x26'} 
                                     } 
                                 }; 
    ... 
    dfdel_acc_lst(dr21_ptr, DFDEL_INCLUDE,DFDEL_ORD,DFDEL_ALL,ord,&include_all);
  • The following example will delete all the LRECs (matching any default or read keys set) in the subfile pointed to by dr21_ptr and all referenced subfiles in the deleted LRECs except for subfiles with record IDs of X'B222' and X'B223':
    static dft_fil *dr21_ptr   = NULL; 
    int ord = 0; 
    struct id_list exclude_all; 
    ... 
    exclude_all.df_nbr_ids = 2; 
    memcpy(exclude_all.df_file_ids, "\xB2\x22", 2); 
    memcpy(exclude_all.df_file_ids+1, "\xB2\x23", 2); 
    dfdel_acc_lst(dr21_ptr, DFDEL_EXCLUDE,DFDEL_ORD,DFDEL_ALL,ord,&exclude_all);