Salesforce

How to automate removal of duplicate records detected by IDXBUILD error 1127

« Go Back

Information

 
TitleHow to automate removal of duplicate records detected by IDXBUILD error 1127
URL NameABL-code-to-automate-removal-of-duplicate-records-detected-by-IDXBUILD-error-1127-in-database-log-file
Article Number000120958
EnvironmentProduct : Progress
Product : OpenEdge
Version: 9.x, 10.x, 11.x, 12.x
OS: All supported platforms
Question/Problem Description
How to use ABL code to automate removal of many duplicate records detected by IDXBUILD error 1127 
How to script IDXFIX Option 6 to delete multiple records using the RECID reported in error 1127 from an IDXBUILD

After running IDXBUILD access to the duplicate record with a unique index fails with 1124 errors

IDXBUILD reports many 1127 errors for duplicate records which need to be removed quickly
Unique key violation leads to corrupted records with duplicate key-fields
When IDXFIX fails with 8783 14761 8779 on unique indexes the duplicate records need to be deleted
 
Steps to ReproduceThe following steps can be used to engineer Unique key violation, to test the ABL code or script provided in the Resolution section below
** These steps are not intended for production environment **

1. prodb sports2000 sports2000
2. proutil sports2000 -C dump customer .
3. proutil sports2000 -C load customer.bd.
4. proutil sports2000 -C idxbuild all.
The CustNum unique index is violated, half the customer records cannot be found:
Fix RECID <recid>, <file-name> already exists with <field value>. (1127)
Clarifying Information
Error MessageFix RECID <recid>, <file-name> already exists with <field value>. (1127)
Defect Number
Enhancement Number
Cause


 
Resolution
To delete individual records by their RECID, the IDXFIX utility can be used by selecting: Option 6.  Delete one record and its index entries This Article compliments the information in the above articles when there are many records to be deleted quickly. It is advisable to:
  • First test this method with the steps to engineer Unique key violation with a sample sports2000 database described above.
  • Assure a valid backup before running record deletion on production.  
  • Using this method to delete records will not fire associated actions defined in delete-triggers
OPTION 1: ABL code to automate deleting duplicate records detected by IDXBUILD error 1127

1. Before running this ABL code:
  • Extract the 1127 messages from the database lg file into a separate text file. 
  • The OpenEdge version must be known due to different database lg file formatting
  • The location of the database .db file 
  • The storage area of each table
This ABL code will ask the following pieces of information:
1. Input File :  Enter the path of the text file created earlier with just the text file with 1127 errors pertaining to just one table.
2. Area number : Area number where the table / duplicate records live.
3. DB path & Name :Enter the path of database.
4.Temp File Name : Name of the temp file (may be necessary to alter location where input entries are generated for each iteration of the loop)
5. Version # of log format : Enter the version of OpenEdge the database log was made by.

Run the following ABL code (which is also attached to the article) to resolve this issue :
DEFINE VARIABLE cInputFile AS CHAR NO-UNDO FORMAT "x(70)" init "d:\db\1127errors.lg".
DEFINE VARIABLE iAreaNumber AS INT NO-UNDO.
DEFINE VARIABLE cOutputFile AS CHAR INIT ".\tempfile" NO-UNDO.
DEFINE VARIABLE cDBPath-Name AS CHAR NO-UNDO FORMAT "x(70)" init "d:\db\sports2000".
DEFINE VARIABLE cInputLine AS CHAR NO-UNDO.
DEFINE VARIABLE cRecid AS CHAR NO-UNDO.
DEFINE VARIABLE cCommandString AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTempFile AS CHAR NO-UNDO INIT ".\fifo.txt".
DEFINE VARIABLE iVersion as int no-undo label "Enter 9, 10, or 11 as version of log file.".

FORM 
  "Input File   :" cInputFile AT 5 SKIP
  "Area Number :" iAreaNumber AT 5 SKIP(1)
  "DB Path&Name :" cDBPath-Name AT 5 SKIP(1)
  "Temp File Name :" cTempFile at 5 SKIP(1)
  "Version # of log format: " iVersion at 5
  WITH FRAME idxfixframe CENTERED NO-LABELS TITLE "1127 IDXFIX Parser".


/* UPDATE cInputFile LABEL "Enter the log file to parse." */
/* UPDATE iAreaNumber LABEL "What area number do the records live in?" */
/* UPDATE cDBPath-Name LABEL "Enter path and dbname." */
/* UPDATE cTempFile LABEL "Enter the temp file to write recids to for idxfix." */
/* UPDATE iVersion with frame idxfixframe . */

UPDATE cInputFile 
 iAreaNumber 
 cDBPath-Name 
 cTempFile  
 iVersion with frame idxfixframe .

INPUT FROM value(cInputFile).

REPEAT:
IMPORT UNFORMATTED cInputLine NO-ERROR.
IF ERROR-STATUS:ERROR THEN LEAVE.

IF INDEX(cInputLine,"(1127)") > 0 THEN
DO:
    RUN trimline(INPUT-OUTPUT cInputLine,INPUT "  ", INPUT " ").  
    if iVersion = 9 then
        cRecid=ENTRY(4, cInputLine, " ").
    if iVersion = 10 then
            cRecid=ENTRY(9, cInputLine, " ").
    if iVersion = 11 then
        cRecid=ENTRY(10, cInputLine, " ").

    cRecid=SUBSTRING(cRecid,1, LENGTH(cRecid) - 1). 
OUTPUT TO value(cTempFile).
PUT UNFORMATTED "6" SKIP 
    cRecid SKIP 
    iAreaNumber SKIP
    "y" SKIP.
OUTPUT CLOSE.

    cCommandString = "proutil " + cDBPath-Name + " -C idxfix<" + cTempFile.
    OS-COMMAND SILENT VALUE(cCommandString).
END.

END.

PROCEDURE trimline:

DEFINE INPUT-OUTPUT PARAMETER cInputLine AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER cFind AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER cChange AS CHAR NO-UNDO.

DO WHILE INDEX(cInputLine,cFind) > 0:
    cInputLine = REPLACE(cInputLine, cFind, cChange).
END.

RETURN cInputLine.
END.

OPTION 2: Script IDXFIX to delete duplicate records detected by IDXBUILD error 1127

OS scripts can be used to achieve the same by feeding the IDXFIX utility with each RECID to delete. This method is particularly useful when a Development License is not available.
  • Only the RECID of the record from error 1127 must be parsed to a text file, each on a new line. Assure there is one additional line after the last RECID entry
  • When the tables are in different storage areas, then create a separate script with distinct parsed RECID for each area from the 1127 errors
UNIX: Script IDXFIX Option 6 to delete multiple records
 
AREANUM=9
DBNAME=sports
for i in `cat duprecidarea9.out`
do
echo 6 > /tmp/resp.txt
echo $i >> /tmp/resp.txt
echo $AREANUM >> /tmp/resp.txt
echo "y" >> /tmp/resp.txt
proutil $DBNAME -C idxfix < /tmp/resp.txt
done

WINDOWS: Script IDXFIX Option 6 to delete multiple records
@echo off
set AREANUM=9
set DBNAME=sports
SETLOCAL EnableDelayedExpansion
for /F "tokens=1" %%i in (duprecidarea9.out) do (
REM set %%i
echo 6 > .\resp.in
echo %%i >> .\resp.in
echo %AREANUM% >> .\resp.in
echo y >> .\resp.in
CALL proutil %DBNAME% -C idxfix < .\resp.in >> .\resp.out 2>&1
)
@echo on


 
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 6:52 AM

Powered by