Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

DeleteKey

Delete key value verifying associated data record position.

Short Name

DELCHK()

Type

Low-Level index file function

Declaration

COUNT DeleteKey(FILNO keyno, pVOID target, LONG recbyt)

Description

In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering

DeleteKey() deletes the key value matching target from index file keyno if such a key value exists and the associated data record position in the index matches recbyt.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful deletion.

3

KMAT_ERR

Could not delete key value, recbyt does not match associated record position in index.

4

KDEL_ERR

Cannot find key value to delete.

See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

LONG recbyt;

FILNO keyno;

TEXT target[24];


keyno = 1;

printf("\nEnter key value: ");

scanf("%23s",target);

if (DeleteKey(keyno, target, recbyt))

printf("\nUnsuccessful deletion (code = %d).",uerr_cod);

else

printf("\n%s deleted (data record position = %ld).", target,recbyt);

Limitations

The following limitation applies only to the Standalone Multi-user model, FPUTFGET: In order to support simultaneous, multi-user updates with guaranteed deadlock free node locks, FairCom DB does not merge “under flowed” nodes (i.e., nodes which are less than half-full). The B-Tree stays balanced in the essential sense that each key value is the same distance from the root as any other key value, but there is no guarantee that each node is at least half full. However, the deleted space can be re-used by new key values.

This limitation is most serious when the key values are systematically deleted from one end of the key value range and systematically added to the other end of the range. Over time, this will lead to a significant amount of wasted disk space.

The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSETHGH() and ctGETHGH() functions to set or get the high-order 4 bytes of the file offset. See also Record Offsets Under Huge File Support.

See also

DeleteKeyBlind, ctSETHGH, ctGETHGH

TOCIndex