ReWriteRecord Rewrite current fixed-length ISAM record. Short Name RWTREC() Type ISAM function Declaration COUNT ReWriteRecord(COUNT datno, pVOID recptr) Description ReWriteRecord() allows changes to be made in the current ISAM record for fixed-length data records belonging to data file number datno. recptr should point to the updated version of the current ISAM record. ReWriteRecord() assumes that the current ISAM record is the original version. After successful completion of ReWriteRecord(), the updated version is now stored in the data file and all necessary changes to the key values associated with the updates are automatically made. The typical ReWriteRecord() usage is:
Unlike c-tree version 4.3 and older, you do not have to be careful about making changes to the current record in your buffer. c-tree Plus maintains its own copy of the current ISAM record key information and position. Multi-user updates are more complex because of the possibility of either locking out the record for prolonged periods, or because of two users trying to update the same record at the same time. See “Multi-User Concepts” in the c-tree Plus Programmer’s Reference Guide for a detailed discussion of multi-user updates. ReWriteRecord() does not change the automatic serial number key segments, if any. If you want the serial number updated, delete the old record and add the updated record. To make the old record the current ISAM record, so that NextRecord() will be performed relative to the position before the update, make the following call after successfully completing the record rewrite: ResetRecord(datno,SWTCURI); Return
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example COUNT datno,keyno; LONG cust_no; TEXT buffer[128];
scanf("%ld",&cust_no);
if (GetRecord(keyno,cust_no,buffer)) /* read current record */ printf("\nCould not read customer record.");
else {
update(buffer); /* make your changes to buffer */ if (ReWriteRecord(datno,buffer)) printf("\nCould not rewrite customer record.");
else printf("\nSuccessful update of customer record.");
} Limitations After a call to ReWriteRecord(), the current ISAM record is set to the new record. This may create a situation that you don’t expect when ReWriteRecord() is used inside a loop that steps over the data in key sequential order. If the key value is changed during the update, the current ISAM record position will skip to the new position, which may be before or after the original position. To avoid this situation, reset the current ISAM record after ReWriteRecord() using ResetRecord(). See also ReadISAMData(), GetRecord(), NextRecord(), ResetRecord() |
||||||||||||||||||||||||||||||||||||||||||