Progress
Language Reference
IMPORT Statement
Reads a line from an input file that might have been created by EXPORT.
SYNTAX
STREAM stream
Specifies the name of a stream. If you do not name a stream, Progress uses the unnamed stream.
DELIMITER character
The character used as a delimiter between field values in the file. The character parameter must be a quoted single character. The default is a space character.
field
The name of a field or variable to which you are importing data. The field or variable must have either the CHARACTER or RAW data type. If the data type is RAW, the IMPORT statement reads enough characters to fill the current length of the variable. If not enough characters are available to fill the current length, the length is reset to the number of characters read.
^
Use a caret (^) to skip a data value in each input line when input is being read from a file.
record
The name of a record buffer. All of the fields in the record are processed exactly as if you had named each of them individually. The record you name must contain at least one field. To use IMPORT with a record in a table defined for multiple databases, qualify the record’s table name with the database name. See the Record Phrase reference entry for more information.
EXCEPT field
Tells Progress to import all the fields except those listed in the EXCEPT phrase.
UNFORMATTED field
Treats each line of the input file as a single string value. In this case, the field parameter must be a single CHARACTER field or variable. You can use this option to read text files one line at a time.
NO-ERROR
Suppresses any errors that occur in the attempt to import the text. After the IMPORT statement completes, you can check the ERROR-STATUS system handle for information on errors that have occurred.
memptr
A variable of data type MEMPTR that contains the imported text. The IMPORT statement my contain a MEMPTR in its field list as long as it is the only field in the list.
EXAMPLESThis procedure takes the data in file
customer.d
and enters it into the Progress database table customer. The procedure uses the DISABLE TRIGGERS statement to stop Progress from executing any triggers for the CREATE, WRITE, and ASSIGN events when loading the data.NOTE: The imported files,customer.d
andcustdump2
, in the next two examples are created by running the example programs under EXPORT.
If the file uses a delimiter other than a space to separate fields, use the DELIMITER option of the IMPORT statement.
You can use the UNFORMATTED option to read the contents of a standard text file. For example, the following procedure reads and displays the contents of the hello file.
In the MEMPTR version of the IMPORT statement, the MEMPTR must be pre-allocated to the size needed for reading. To get the length to read for an imported file, use the FILE_INFO system handle and the SET-SIZE statement as follows:
NOTES
- You cannot use the IMPORT statement to read data from the screen. Before the IMPORT statement is executed, you must redirect output (usually with an INPUT FROM statement).
- If you do not use the UNFORMATTED option, the data in the input stream must be in a standard format to be read back into Progress. You must enclose all character fields in quotes (
""
) if they contain any delimiter characters. If you want to import any quotes contained in the data, replace them with two quotes ("" ""
). You must display an unknown value as an unquoted question mark (?).- If an input data line contains an unquoted hyphen in place of a data value, then the corresponding field is skipped, as it is in UPDATE. If you specify a hyphen (-) as the delimiter character, all hyphens are treated as delimiters. If you use the UNFORMATTED option, the hyphen is treated the same as any other character.
- A period (.) on a line by itself is treated as an end-of-file indicator. The ENDKEY is applied, but the file or stream remains open for input.
- Data read in with IMPORT is not restricted by frame-related format statements, as is data read in by SET or UPDATE. Since IMPORT does not have to validate the input stream, it is faster than SET or UPDATE.
- IMPORT is sensitive to the Date Format (-d), Century (-yy), and European Numeric Format (-E) parameters. When loading data with the IMPORT statement, use the same settings that you used with the EXPORT statement.
- Progress interprets the null character as a terminator.
- The UNFORMATTED option forces IMPORT to read one physical line at a time. A physical line ends with a newline or linefeed character.
- In the MEMPTR version of the IMPORT statement, the MEMPTR must be pre-allocated to the size needed for reading. See the example, r-impmem.p, above.
SEE ALSO
DEFINE STREAM Statement, DISABLE TRIGGERS Statement, DISPLAY Statement, EXPORT Statement, INPUT FROM Statement, INPUT CLOSE Statement, PUT Statement, STRING Function
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |