KI_READ_HOLD

Read a random row and lock

Synopsis:
CALL KI_READ_HOLD handle, key$, path, SYM(rowbuf$), [eLockType], [bQuery] TO status, [rowid$]
'ki_read_hold( handle, key$, path, SYM(rowbuf$), [eLockType], [bQuery], [rowid$] )
ArgumentEnumerationPurpose
handleHandle
key$Key index to row
pathIndex path
SYM(rowbuf$)Symbol of row buffer
eLockTypeKCML_KDB_LOCK_ENUMOptional lock type
bQueryForce use of DEFQUERY
statusKDB_ERROR_ENUMReturn status
rowid$Row ID
>KI_READ_HOLD

KI_READ_HOLD

Reads a random row and locks it for later update or deletion.

Reads row with key key$ on path path into buffer whose SYM() index is sym. If the read was successful, then the rowid$ variable will contain the ROWID of the row. If the read failed, then rowid$ will be ALL(00) and the status will be KE_NOTFOUND if no such key is in the index, or KE_LOCKED if present but locked by another process.

In order to be able to later update or delete the row with KI_REWRITE or KI_DELETE, it must be held and locked by setting the optional eLockType argument to one of the enumerated constants. The lock can be either a short term transactional lock or a long term lock. As many rows as are required may be held at any time.

It is an error to take a long term lock inside a transaction except in the special case of a redundant lock on a row that was previously locked by the process outside the transaction.

Compatibility note:

On early versions of the KCML database the row was locked by setting the lock byte to binary #PART. From KCML 3.20 onwards the locking is done by locking the range of bytes that the row data occupies. From KCML 6.60, KDB distinguishes long term locks from transactional locks on some databases by using the eLockType enumeration.

History
Introduced in KCML 3.00
See Also:
KI_BUILD, KI_COPY_TABLE, KI_CREATE, KI_CREATE_TMP, KI_DELETE, KI_DELETE_ROWS, KI_DELETE_WHERE, KI_END, KI_ERROR, KI_ERROR_TEXT, KI_FETCH, KI_GET_ERROR_TEXT, KI_GET_SERIAL, KI_GROW, KI_INFO, KI_INITIALISE, KI_LOCK_ALL, KI_LOCK_OWNER, KI_MOVE_ROWS, KI_MOVE_TABLE, KI_OPEN, KI_READ, KI_READ_ARRAY, KI_READ_HOLD_NEXT, KI_READ_HOLD_PTR, KI_READ_NEXT, KI_READ_PTR, KI_READ_RANDOM, KI_READ_RAW, KI_REBUILD, KI_REWRITE, KI_SET_EXTENT, KI_SET_ROWS, KI_SET_SERIAL, KI_SET_WLOCK_COUNT, KI_SIZE_FILE, KI_START, KI_START_BEG, KI_START_BETWEEN, KI_START_FIRST, KI_START_ON, KI_START_ROW, KI_START_ROW_BETWEEN, KI_UNLOCK, KI_UNLOCK_FILE, KI_VERIFY, KI_WMODE_BITMAP, KI_WRITE, KI_WRITE_PTR, KI_WRITE_RAW, KI_WS_CREATE, KI_WS_DELETE, KI_WS_OPEN, KI_WS_READ, KI_WS_REWRITE, KI_WS_WRITE
KCML database status codes