fdelrec() — Delete a VSAM record

Standards

Standards / Extensions C or C++ Dependencies
Language Environment both  

Format

#include <stdio.h>

int fdelrec(FILE *stream);

#define _OPEN_SYS_UNLOCKED_EXT 1
#include <stdio.h>

int fdelrec_unlocked(FILE *stream);

General description

Removes the record previously read by fread() from the VSAM file associated with stream. The fdelrec() function can only be used after an fread() call has been performed and before any other operation on that file pointer. For example, if you need to acquire the file position using ftell() or fgetpos(), you can do it either before the fread() or after the fdelrec(). An fread() after an fdelrec() will retrieve the next record.

To avoid infringing on the user's name space, this nonstandard function has two names. One name is prefixed with two underscore characters, and one name is not. The name without the prefix underscore characters is exposed only when you use LANGLVL(EXTENDED).

To use this function, you must either invoke the function using its external entry point name (that is, the name that begins with two underscore characters), or compile with LANGLVL(EXTENDED). When you use LANGLVL(EXTENDED) any relevant information in the header is also exposed.

The fdelrec() function can be used with key sequenced data sets (KSDS), KSDS PATHs, and relative record data set (RRDS) opened in an update mode (that is, rb+/r+b, wb+/w+b, or ab+/a+b), with type=record.

VSAM does not support deletions from ESDSs.

fdelrec_unlocked() is functionally equivalent to fdelrec() with the exception that it is not thread-safe. This function can safely be used in a multithreaded application if and only if it is called while the invoking thread owns the (FILE*) object, as is the case after a successful call to either the flockfile() or ftrylockfile() function.

Returned value

If successful, fdelrec() returns 0.

If unsuccessful, fdelrec() returns nonzero.

Example

/* This example shows how a VSAM record is deleted using the fdelrec()
   function.
 */
#include <stdio.h>
   FILE *stream;
   char buf[80];
   int num_read;
   int rc;
   stream = fopen("DD:MYCLUS", "rb+,type=record");
⋮
   num_read = fread(buf, 1, sizeof(buf), stream);
   rc = fdelrec(stream);
⋮

Related information