Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

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(FILNO datno, pVOID recptr, VRLEN varlen)

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 TypeDef Change

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.

As of c-tree V8.14, c-tree sets the current ISAM position after a record is added such that the next or previous record can be read without having to re-read the record just added. Prior to V8.14, the current ISAM position was not set to a newly-added record and an INOT_ERR (101) error would result if you tried to read either the next of previous record.

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 FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

FILNO 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

ISAM Functions discusses how the relationship among the data files and their corresponding index files is specified. Begin, Commit, LockCtData, LockISAM, SetOperationState, Commit, LockISAM

TOCIndex