Kbase P35106: Only part of a file is being imported using IMPORT.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  23/09/2003 |
|
Status: Unverified
SYMPTOM(s):
Only part of a flat file is being imported using IMPORT.
** <file-name> already exists with <field/value...>. (132)
Importing a flat file into a temp table with a unique index. The flat file structure is similar to:
1,A
2,A
2,A
3,A
3,A
4,A
5,A
6,A
6,A
The code being used is similar to:
DEFINE TEMP-TABLE ttTableName NO-UNDO
FIELD iUnique AS INTEGER
FIELD cString AS CHARACTER
INDEX puIndex AS PRIMARY UNIQUE iUnique.
INPUT FROM FlatFile.dat.
REPEAT:
CREATE ttTableName.
IMPORT DELIMITER "," ttTableName NO-ERROR.
END.
INPUT CLOSE
CAUSE:
When the first duplicate record is encountered, error 132 is generated and when the RETRY fails, the ERROR condition is is raised to a LEAVE and we are left with the records that have been imported before the error occurred.
FIX:
Ensure that the record is not a duplicate record before its creation as per the following code:
DEFINE TEMP-TABLE ttTableName NO-UNDO
FIELD iUnique AS INTEGER
FIELD cString AS CHARACTER
INDEX puIndex AS PRIMARY UNIQUE iUnique.
DEFINE VARIABLE cRecord AS CHARACTER NO-UNDO.
INPUT FROM FlatFile.dat.
REPEAT:
IMPORT UNFORMATTED cRecord NO-ERROR.
IF CAN-FIND(ttTableName WHERE iUnique = INTEGER(ENTRY(1, cRecord))) THEN NEXT.
RUN CreateRecord(cRecord).
END.
INPUT CLOSE.
PROCEDURE CreateRecord.
DEFINE INPUT PARAMETER pcRecord AS CHARACTER NO-UNDO.
CREATE ttTableName NO-ERROR.
ASSIGN
iUnique = INTEGER(ENTRY(1, pcRecord))
cString = ENTRY(2, pcRecord) NO-ERROR.
END PROCEDURE.