F.93 DeleteRecord
Delete current fixed length ISAM record.
Short Name
DELREC
TYPE
ISAM fixed length record function
DECLARATION
COUNT DeleteRecord(COUNT datno)DESCRIPTION
DeleteRecord deletes the current fixed-length ISAM record for data file datno. If the data record is successfully deleted, DeleteRecord updates all associated index files and returns the data record to the pool of available records for data file datno. After the deletion, the current ISAM record information stays unchanged! That is, even though the current record has just been deleted, the information in the current ISAM buffer is not disturbed so that you can scan in either direction through the data via the NextRecord or PreviousRecord routines.
In multi-user systems, invoke LockISAM(ctENABLE) before the ISAM routine which reads the record to be deleted. Call LockISAM(ctFREE) after DeleteRecord To release the locks. See the example below.
DeleteRecord does not shrink the files. c-tree Plus tracks and reuses deleted space before expanding the files. To remove all deleted space, compact the file using CompactIFile or CTCMPC.
RETURN
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
COUNT invfil,part_no_idx;LONG part_key;struct invd {TEXT delflg[4];LONG part_no;TEXT part_name[60];} recbuf;printf("\nEnter part number to delete: ");scanf("%ld",&part_key);if (LockISAM(ctENABLE))printf("\nCould not enable locks.");else if (GetRecord(part_no_idx, &part_key, &recbuf))printf("\nCould not get PART #%ld (%d %d).",part_key, isam_err, isam_fil);else if (DeleteRecord(invfil))printf("\nCould not delete PART #%ld (%d %d).",part_key, isam_err, isam_fil);LockISAM(ctFREE);LIMITATIONS
DeleteRecord causes the first byte of the data record to be set to ff (hex) as a delete flag. This flag is tested by all ISAM functions which read a data record. If the first byte is equal to ff (hex), error 114 (IRED_ERR) is returned. The delete flag is also used by the rebuild utility to determine if a record is deleted. When you define your data record structure, the most straightforward approach is to reserve the first byte of the data record for the delete flag. You may store data in the first byte as long as the data will never be equal to ff (hex).
Fixed-length data files with RESOURCES enabled use the first byte to indicate the presence of a resource record. A byte value of fe (hex) at the beginning of the record indicates a resource record.
SEE ALSO
DeleteVRecord and 3.3.2 IMPORTANT - Data Record Delete Flag on page 3-7 in the c-tree Plus Programmer's Reference Guide.
|
FairCom Corporation www.faircom.com |