Consultor Eletrônico



Kbase 16816: How To Import Data That Is Not Broken Into Separate Records
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How To Import Data That Is Not Broken Into Separate Records

The following code shows how to import data that has each record
located immediately after the previous record without any sort of
CR/LF (or other delimiter) between each record.


NOTE: This program only works with version 8.2 and higher.


/*-------------------------------------------------------------*/
/* This program demonstrates how to input data from a file */
/* when the data is not broken out into separate lines. */
/*-------------------------------------------------------------*/

DEFINE TEMP-TABLE ExtData NO-UNDO
FIELD cField AS CHARACTER FORMAT "X(2)"
FIELD iField AS INTEGER FORMAT "9999".

DEFINE VARIABLE ExtRecord AS RAW NO-UNDO.
DEFINE VARIABLE ExtField1 AS CHARACTER NO-UNDO FORMAT "X(2)".
DEFINE VARIABLE ExtField2 AS CHARACTER NO-UNDO FORMAT "X(4)".

DEFINE STREAM ExtStream.

ASSIGN LENGTH(ExtRecord) = 6. /* Put Record Length Here */

INPUT STREAM ExtStream FROM TEST.DAT.

REPEAT:
IMPORT STREAM ExtStream UNFORMATTED ExtRecord.
ASSIGN ExtField1 = GET-STRING(ExtRecord,1)
ExtField2 = GET-STRING(ExtRecord,3) NO-ERROR.
IF ExtField1 NE '' AND ExtField2 NE '' THEN
DO:
CREATE ExtData.
ASSIGN ExtData.cField = ExtField1
ExtData.iField = INTEGER(ExtField2).
DISPLAY ExtData.
END.
END.

INPUT STREAM ExtStream CLOSE.

ASSIGN LENGTH(ExtRecord) = 0.


The following data file was used to test this program:

AA1111BB2222CC3333DD4444EE5555FF6666GG7777HH8888II9999

Progress Software Technical Support Note # 16816