The GET_LINE procedure reads a line of data from a file based on the file handle and the specified length. The data is read starting from the offset where the file was last read. The procedure stops reading when it encounters a line break.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
UTL_FILE.GET_LINE (
file IN FILE_TYPE,
buffer OUT VARCHAR2,
len IN PLS_INTEGER DEFAULT NULL);
Parameters
| Parameter | Description |
|---|---|
| file | The file handle for reading the file. The file must be opened in the r mode. |
| buffer | The output parameter used to store the data that is read. You must make sure that the length of this parameter is greater than another parameter len. |
| len | The number of bytes to be read. If you do not specify this parameter, the system specifies it based on the max_linesize parameter when the file is opened. |
Exceptions
INVALID_FILEHANDLEINVALID_OPERATIONNO_DATA_FOUNDREAD_ERROR
Considerations
You must open the file in the
rmode. Otherwise, anINVALID_OPERATIONexception will be thrown.If the line to be read cannot fit into the buffer, an
READ_ERRORexception will be thrown; if the end of the file is reached and no text is read, aNO_DATA_FOUNDexception will be thrown; if the file is opened in the byte mode, anINVALID_OPERATIONexception will be thrown.Since the line break is not read into the buffer, reading an empty line returns an empty string.
The maximum length of the buffer is 32,767 bytes if the
max_linesizeparameter is not specified inFOPEN. The default value is 1,024.