Consultor Eletrônico



Kbase P4129: Import into a temp-table or work-table creates a blank record
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/3/2009
Status: Verified

SYMPTOM(s):

Import of text file into a temp-table or work-table creates a blank record

Text file is generated with an export statement

File imported using REPEAT: IMPORT ... loop.

Import statement reads one empty line at the end of file without errors

Blank record is created

Occurs only with work-tables and temp-tables, not with database tables

Temp-table / work-table is undoable (not defined as no-undo)

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

CAUSE:

Modifying the data in a temp-table does not start a transaction by default. (This is different from updating database tables where transactions are a requirement to maintain multi-user concurrency and congruity.)
So what happens is the following:
- After reading the last line from the input, the repeat loop iterates and does a CREATE of a temp/work-table record.
- Then the IMPORT fails due to end of file and undoes the last iteration.
- But since there is no active transaction, the undo property of the temp/work-table has no effect and the last create is not undone.

FIX:

In most cases, simply deleting the blank record after the import is the more desirable solution. This provides better performance by avoiding the overhead from the transaction mechanism.

Otherwise, to make the import for loop work the same for a temp-table as for a database table, use TRANSACTION keyword on the REPEAT statement.

REPEAT TRANSACTION:
CREATE tt.
IMPORT tt.
END.

Also make sure the temp-table is not defined as NO-UNDO. For this to work as expected, it must be possible to undo changes made to the temp-table.