OpenTP1 Version 7 Programming Reference C Language

[Contents][Index][Back][Next]

dc_dam_read - Input a logical file block

Format

ANSI C, C++

#include <dcdam.h>
int  dc_dam_read (int damfd, struct DC_DAMKEY *keyptr,
                  int keyno, char *bufadr, int bufsize,
                  DCLONG flags)

K&R C

#include <dcdam.h>
int  dc_dam_read (damfd, keyptr, keyno, bufadr, bufsize,
                  flags)
int      damfd;
struct DC_DAMKEY *keyptr;
int      keyno;
char     *bufadr;
int      bufsize;
DCLONG   flags;

Description

The function dc_dam_read() inputs a block (which is in the specified range) for reference or update processing from the specified logical file

When inputting a logical file block, specify the file descriptor which is the return value of the function dc_dam_open().

Arguments whose values are set in the UAP

damfd

Specify the file descriptor of the file containing a block to be input.

keyptr

Specify the address of the structure (DAM key) that indicates the block reference/update range. For the structure, specify the block range with the first relative block number and the last relative block number. The structure format is as shown below.

struct DC_DAMKEY {
                  int fstblkno;
                  int endblkno;
                 };

keyno

Specify the number of structures (number of structure arrays) to be set for keyptr.

bufadr

Specify the address of the input buffer.

bufsize

Specify the length of the input buffer. The length must be equal to or greater than (input block length x number of blocks). You can specify a value in the range from 504 to 2147483647.

flags

Specify the type of request (reference request or update request) in the following format:

{DCDAM_REFERENCE|DCDAM_MODIFY}
[|{DCDAM_EXCLUSIVE|DCDAM_NOEXCLUSIVE}]
[|{DCDAM_WAIT|DCDAM_NOWAIT}]

If both items are omitted, the subsequent processing is as follows:

The table below shows the correspondence between flag values specified for flags and the specified type of lock.

Flag 1 Flag 2#1 Flag 3#2 Lock Specified for Flags
REFERENCE EXCLUSIVE WAIT Input for reference, lock used, and waiting for release from lock if a lock error occurs
NOWAIT Input for reference, lock used, and error return if a lock error occurs
NOEXCLUSIVE N/A Input for reference, and lock not used#3
MODIFY N/A WAIT Input for update, and waiting for release from lock if a lock error occurs
NOWAIT Input for update, and error return if a lock error occurs

Legend:
N/A: Cannot be specified.

#1: The default is NOEXCLUSIVE.

#2: The default is the type of lock specified in the function dc_dam_open().

#3: For a recoverable DAM file, the function dc_dam_read() can be called from a process out of the transaction range only if flag 1 is given the value DCDAM_REFERENCE and flag 2 is given the value DCDAM_NOEXCLUSIVE or is omitted. If the function dc_dam_read() is called with other values specified for the flags from outside the transaction range, it returns with a DCDAMER_PROTO error.

Return values

Return value Return value (numeric) Explanation
DC_OK 0 All blocks were input normally.
DCDAMER_PROTO -1600 The function dc_rpc_open() is not called.
The purpose of input is updating or lock-specified reference outside the transaction range. (This value is returned only when a recoverable DAM file is accessed.)
N is specified for atomic_update in the user service definition. (This value is returned only when a recoverable DAM file is accessed.)
The function dc_dam_start() is not called. (This value is returned only when an unrecoverable DAM file is accessed.)
The UAP is incorrectly linked as follows:
  • The library (-1tdam) to be used for access to a TAM file using a DAM service function is linked incorrectly.
  • The definition of the resource manager for transaction control object files is incorrect.
DCDAMER_EXCER -1602 A lock error occurred.
DCDAMER_BADF -1603 The file descriptor specified for damfd is not the one which was acquired by opening the file normally, or the specified file is not open.
DCDAMER_BUFER -1604 The specified input buffer is too small to contain all blocks.
The value specified for the input buffer length is outside the range of values that can be specified.
DCDAMER_BNOER -1606 The relative block number is invalid.
DCDAMER_NOMEM -1607 The memory became insufficient.
DCDAMER_PARAM_KEYNO -1609 The value specified for keyno is smaller than 1.
DCDAMER_PARAM_FLAGS -1611 The value specified for flags is invalid.
DCDAMER_VERSION -1618 The version of the DAM library linked to the UAP does not allow the UAP to operate with the current DAM service.
DCDAMER_JNLOV -1613 The number of block updates exceeded the maximum number of blocks that can be updated during one transaction according to the DAM service definition. (Returned only when a recoverable DAM file is accessed.)
DCDAMER_IOER -1620 An input error occurred.
DCDAMER_LHOLD -1621 The file of the file descriptor specified for damfd is in logical shutdown state.
DCDAMER_OHOLD -1622 The file with the file descriptor specified for damfd is in shutdown state due to an error.
DCDAMER_ACCESS -1628 A DAM file to be accessed is protected with the security facility. The UAP that called the function dc_dam_read() has no access permission.
DCDAMER_TMERR -1629 An error occurred in the transaction service. (This value is returned only when a recoverable DAM file is accessed.)
DCDAMER_DLOCK -1642 A deadlock occurred.
DCDAMER_TIMOUT -1643 The resource could not be acquired because a timeout occurred (the wait time specified in the lock service definition was exceeded).
DCDAMER_LCKOV -1645 The number of lock requests exceeds the specified maximum number of concurrent lock requests.
DCDAMER_ACSOV -1648 The maximum number of blocks for access to unrecoverable DAM files is exceeded. (This value is returned only when an unrecoverable DAM file is accessed.)