While RECIDs should never be relied on for
referential integrity, using an INT64 data type instead of a RECID database allows the field value stored to be preserved and avoids index corruption when it is part of a key index. To change a Field from a RECID to an INT64 datatype requires adding a new field with the required data type:
Assume the following TABLOG Schema:
ADD FIELD "TABLE_ID" OF "TABLOG" AS RECID
DESCRIPTION "Record ID of record"
FORMAT ">>>>>>>>9"
INITIAL ?
LABEL "RecID"
MANDATORY
ADD INDEX "I_TABLOG" ON "TABLOG"
AREA "Primary Index Area"
UNIQUE
INDEX-FIELD "TABLE_ID" ASCENDING # recid data type
INDEX-FIELD "NAME" ASCENDING # character data type
INDEX-FIELD "TABSEQ" ASCENDING # decimal data type trigger via sequence NextTABLOG"
1. Through the Data Dictionary:
a. Deactivate the I_TABLOG index
The index needs to be re-created later anyway. Otherwise the index will be rebuilt when its key field TABLE_ID is renamed next.
If the index is a PRIMARY INDEX, consider temporarily marking another active index as the Primary Index. Refer to Article:
b. Re-name the RECID data type field TABLE_ID to: temp-TABLE_ID
c. (re-)Create field TABLE_ID, by copying temp-TABLE_ID then selecting: Modify First
Field Name: TABLE_ID
Data Type: INT64
DESCRIPTION "Record ID of record Record as INT64"
2. Copy the field values of temp-TABLE_ID to TABLE_ID
The following example ABL can be run from a client session;
DISABLE TRIGGERS FOR LOAD OF TABLOG.
FOR EACH TABLOG:
ASSIGN TABLE_ID = temp-TABLE_ID.
END.
3. Re-create the index by deleting the current index and adding it back again (inactive).
The following .df can be used (the customer's "AREA" for indexes will need to be edited)
RENAME INDEX "I_TABLOG" TO "temp-30828" ON "TABLOG"
ADD INDEX "I_TABLOG" ON "TABLOG"
AREA "Primary Index Area"
UNIQUE
INACTIVE
INDEX-FIELD "TABLE_ID" ASCENDING # now an INT64 data type
INDEX-FIELD "NAME" ASCENDING
INDEX-FIELD "TABSEQ" ASCENDING
DROP INDEX "temp-30828" ON "TABLOG"
DROP FIELD "temp-TABLE_ID" OF "TABLOG"
4. Build the I_TABLOG index with IDXACTIVATE (online) or IDXBUILD (offline)
$ proutil dbname -C idxactivate TABLOG.I_TABLOG
5. When the data type of a database field is changed, this effects the Cyclic Redundancy Check (CRC) of the database table that contains the field. Any r-code derived from ABL code which references this table must be recompiled.