Table of Contents
This field plays the role of an unique identifier of a record in the scope of its VTable.
The RecID field is of ULONG type (4 bytes). This fact applies a limit for the number of records per table at 2^32 = 4 billions.
RecID means actually the physical number of a record, so Valentina does not store RecID values on hard disk. On pictures we draw the RecID field and its values on the left of the table to underline this fact.
The first physical record has a RecID equal to 1. The zero RecID value is used for an undefined record.
A record gets its RecID value when it is inserted into VTable. The RecID value is never changed during the lifetime of the record. Deleted records are marked in the Deletion Bitmap of VTable, but records are not moved physically as this happens for DBMS that use page-files to keep records.
RecID and Record Migration
Record can change RecID only if it migrates to other database.
If you export pair of records related by RecID + ObjectPtr then you can easy “convert” this into PK + FK pair, as we do this in the relational databases.
On import of such pair into other database, it is clear that RecID and ObjectPtr values must be changed. Value of RecID field should be stored in the ObjectPtr field of Valentina. In this case Valentina will automatically correct values of ObjectPtr fieldы for such operations as db.Clone() or load of dumps.
RecID Field Access
You can access the RecID field only by name. Remember that the RecID field is of the type ULong, and you may need to cast to this type to get/set its value.
RecID Field in SQL
Valentina seamlessly integrates the RecID field into SQL. You can use it in any SELECT query. Note that “SELECT * …” does neither select the RecID nor other Table Methods. You need to use “SELECT ** …” or specify the RecID field explicitly by name.
SELECT * FROM T -- does not select RecID but only custom fields. SELECT ** FROM T -- selects custom fields and RecID, OID and all other Table methods. SELECT RecID, f1, f2 FROM T -- selects 3 fields. SELECT f1, f2 FROM T ORDER BY RecID -- actually not very useful but works. DELETE FROM T WHERE recid IN (SELECT fldObjectPtr FROM T2)
Note that since the RecID field is a Table Method and therefore read-only, there is no sense in using it in the INSERT command. Even if you specify that, Valentina simply ignores it.