FairCom Corporation


F.6 AddVRecord


Add a new variable-length data record, and its corresponding key values, to ISAM files.

SHORT NAME

ADDVREC

TYPE

ISAM function variable length record

DECLARATION

COUNT AddVRecord(COUNT datno, pVOID recptr, VRLEN varlen)

DESCRIPTION

AddVRecord adds the data record with length in bytes given by varlen and pointed to by recptr to data file number datno. It automatically adds the key values defined for the data file to their respective index files. If successful, the new data record becomes the current ISAM record for datno. In multi-user applications, AddVRecord automatically causes a data record lock to be placed on the new record. Therefore, LockISAM(ctENABLE) and LockISAM(ctFREE) should be called before and after AddVRecord. However, if you are using transaction processing, (single-user and client/server models only), you will usually enable and free locks during the Begin and Commit functions.

RETURN

Value
Symbolic Constant
Explanation
0
NO_ERROR
Successful addition of a new data record.
2
KDUP_ERR
Duplicate key value found in index file number isam_fil. Data record not added and no key values inserted.
33
DNUL_ERR
recptr is null. No action taken.
37
WRITE_ERR
Most likely disk or directory is full. Files are left in an indeterminate state and should be rebuilt.
48
FMOD_ERR
datno is assigned to a fixed record length file.
147
VDLFLG_ERR
Attempt to re-use a data record that is still active. Apparently, the data file is corrupted in which case you should rebuild the ISAM files.
149
VRLN_ERR
varlen is less than the minimum record length for this variable-length file.
199
NSCH_ERR
key segment refers to schema, but schema not defined.
433
SSCH_ERR
Segment definition inconsistent with schema.
445
SDAT_ERR
Not enough data to assembly key.
446
BMOD_ERR
Invalid key mode.

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;
struct invd {
LONG part_no;
LONG on_hand;
TEXT part_name[120];
} recbuf;
scanf("%ld %ld %119s",&recbuf.part_no,&recbuf.on_hand,
recbuf.part_name);
if (LockISAM(ctENABLE) || AddVRecord(invfil,&recbuf,8 +
strlen(recbuf.part_name)) || LockISAM(ctFREE))
printf("\nAddVRecord error %d in file %d",isam_err, isam_fil);

SEE ALSO

The Chapter 5 "ISAM Functions" of the c-tree Plus Programmer's Reference Guide discusses how the relationship among the data files and their corresponding index files is specified.


FairCom Corporation
www.faircom.com