Consultor Eletrônico



Kbase 20591: Possible Reason For Error 132 When Copying Records
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/25/2003
Status: Unverified

SYMPTOM(s):

** <file-name> already exists with <field/value...>. (132)

Trying to copy a record with NO-ERROR on any of the following statements: BUFFER-COPY, RAW-TRANSFER, or ASSIGN

CAUSE:

The following depicts a fairly common data replication procedure where a record in "Database1" is being copied into "Database2".

FIND FIRST Database1.Benefits NO-ERROR.
IF AVAILABLE Database1.Benefits THEN DO:
CREATE Database2.Benefits.
BUFFER-COPY Database1.Benefits TO Database2.Benefits NO-ERROR.
END.

On the surface, the preceding procedure looks valid, in that it will suppress the error message that would be generated by the BUFFER-COPY statement if a duplicate record is found in Database2.

The usage of the NO-ERROR option, however, is only half the battle.
There is still a Database2.Benefits record with initial values hanging around and, at the end of the transaction (whether it be scoped to the procedure or a transaction block) there is an attempt to write that record to the database again and the results would be the error 132.

FIX:

The key to getting around this is to check the ERROR-STATUS:ERROR attribute directly after the BUFFER-COPY, RAW-TRANSFER or ASSIGN statement is executed with NO-ERROR and, if it returns TRUE, delete the empty buffer.

FIND FIRST Database1.Benefits NO-ERROR.
IF AVAILABLE Database1.Benefits THEN DO:
CREATE Database2.Benefits.
BUFFER-COPY Database1.Benefits TO Database2.Benefits NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DELETE Database2.Benefits.
END.