IFS_READ, IFS_READ_BINARY, and IFS_READ_UTF8 table functions
The IFS_READ, IFS_READ_BINARY, and IFS_READ_UTF8 table functions read an integrated file system stream file identified by path-name. The file's data is returned as character, binary, or UTF-8 data. It can be returned as one string of data, or it can be broken into multiple lines using a specified length or end of line characters.
Authorization: The caller must have:
- For objects not in the QSYS.LIB file system:
- Execute (*X) data authority to each directory preceding the stream file being read and
- Read (*R) data authority to the stream file
- For objects in the QSYS.LIB file system:
- Execute (*X) data authority to each directory preceding the object being read and
- For a *SAVF object, Read, Write, and Execute (*RWX) data authority to the object
- For all other object types, Read (*R) data authority to the object
- Execute (*X) data authority to each directory preceding the object being read and
The schema is QSYS2.
- path-name
- An expression that returns the path name identifying the stream file to read. A relative path name is relative to the current directory. If an absolute path name is not specified, the current working directory is used in combination with the relative path name to resolve to the object. If the object is not a stream file, an error is issued.
- maximum-line-length
- An integer value that specifies the maximum number of characters returned for each line. It must be greater than 0. The default is 2 gigabytes.
- end-of-line
- A character or graphic string that specifies the end of line characters to be recognized in the stream file. Each occurrence of an end of line sequence determines a line which is returned. The end of line character sequence is not returned with the line. When using IFS_READ_BINARY, end of line characters are never processed, so this parameter must have a value of NONE.
- ignore-errors
-
A character or graphic string expression that identifies what to do when an error is encountered.
- NO
-
An error is returned.
- YES
- A warning is returned.
The result of the function is a table containing rows with the format shown in the following table. All the columns are nullable.
Column Name | Data Type | Description |
---|---|---|
LINE_NUMBER | INTEGER | Relative position of this line in the stream file. |
LINE |
For IFS_READ:
CLOB(2G) For IFS_READ_BINARY: BLOB(2G) For IFS_READ_UTF8: CLOB(2G) CCSID 1208 |
The data for this line.
|
Example
- Read the data from stream file /usr/file1. Break lines when a carriage return/line feed
sequence is encountered. The result will be in the job's
CCSID.
SELECT * FROM TABLE(QSYS2.IFS_READ(PATH_NAME => '/usr/file1', END_OF_LINE => 'CRLF'));
- Read the data from stream file /usr/file2. If the file size is less than 2 gigabytes, the
result will be a single row containing the entire file. If the file size is greater than 2
gigabytes, multiple rows will be
returned.
SELECT * FROM TABLE(QSYS2.IFS_READ_BINARY(PATH_NAME => '/usr/file2'));