Salesforce

How to change a RECID Data Type to INT64

« Go Back

Information

 
TitleHow to change a RECID Data Type to INT64
URL NameHow-to-change-a-RECID-Data-Type-to-INT64-000086658
Article Number000134418
EnvironmentProduct: OpenEdge
Version: 10.1B, 10.1C, 10.2x, 11.x
OS: All supported platforms
Question/Problem Description
How to change a database field RECID Data Type to INT64
Using a RECID datatype necessitates alternatives when designing application logic around RECID's in order to preserve values
Since 10.1B using an INT64 datatype instead of RECID avoids potential index corruption
 
Steps to Reproduce
Clarifying Information
Use Cases:

Preserving RECID datatype values.
  • Data Dictionary dump excludes RECID datatype values. When the field is MANDATORY, the values are imported with an initial value "?", otherwise RECID data values are lost.
  • RECID data values are lost unless the RECID field name is included in an EXPORT statement
Index Corruption.

Prior to OpenEdge 11.6.4, 11.7.2, the routine used by index utilities, (idxcheck, idxfix, idxbuild, idxactivate) processes ROWID datatype fields as an INTEGER field when validating or building keys.  When the value is in the 64 bit range and part of an index key, the routine used by index utilities, (idxcheck, idxfix, idxbuild, idxactivate) processes RECID datatype fields as an INTEGER field when validating or building keys. Refer to Article Prior to OpenEdge 11.7.0; 11.6.4, when recids straddle the 32/64-bit boundary, multi-level indexes are corrupted when the index grows larger than can be referenced by a 32-bit variable.  Refer to Article
Error Message
Defect Number
Enhancement Number
Cause
Resolution
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.
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:11 AM

Powered by