Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

GetSerialNbr

Get current data file sequence number.

Short Name

SERIALNUM()

Type

Low-Level data file function

Declaration

LONG GetSerialNbr(FILNO datno)

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

GetSerialNbr() returns the current sequence number for data file datno used in ISAM applications using a SRLSEG key segment mode. Use ctGETHGH() to retrieve the high-word portion of an 8-byte sequence number.

When the SRLSEG key segment mode is used in an index, each call to NewData() or NewVData() increments the sequence number in the header of the associated data file. Calls to AddRecord() and AddVRecord() automatically invoke NewData() and NewVData(), respectively.

To manually manage serial numbers, use the OPS_SERIAL_UPD status_word described in the SetOperationState() function description.

Return

GetSerialNbr() returns a long integer containing the current sequence number. If an error occurs (such as data file not in use), GetSerialNbr() returns a zero value. Check uerr_cod for the error code. See c-tree Error Codes in the c-tree Programmer’s Reference Guide for a complete listing of valid c-tree error values.

Example

FILNO datno;


if (OpenCtFile(datno,"MYDATA.DAT",(ctVIRTUAL | ctEXCLUSIVE))){

printf("\nCould not open data file with error %d", uerr_cod);

exit(2);

}

printf("\n Last used sequence number for MYDATA is %ld.",

GetSerialNbr(datno));

exit(0);

Limitations

Serial numbers are not guaranteed to be sequential.

See also

ctGETHGH(), NewData(), NewVData(), AddRecord(), AddVRecord(), SetOperationState and ISAM Functions (ISAM Database Technology, /doc/ctreeplus/30841.htm) in the c-tree Programmer’s Reference Guide.

TOCIndex