FairCom Corporation


F.91 DeleteKey


Delete key value verifying associated data record position.

Short Name

DELCHK

TYPE

Low level index file function

DECLARATION

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

DESCRIPTION

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 Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

EXAMPLE

LONG recbyt;
COUNT 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, c-tree Plus 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.

If an application deletes a substantial portion of the index entries, disk space can be saved by compacting the index via the CTCMPC utility program.

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

DeleteKeyBlind.


FairCom Corporation
www.faircom.com