Retrieves the next line of an open fileand places it in item. Text_IO.Get_Line reads characters until a newline character (i.e., carriage return) is read or an end-of-file (EOF) condition is encountered. If the line to be read exceeds the size of item, the Value_Error exception is raised. If there are no more characters remaining in the file, the No_Data_Found exception is raised.
PROCEDURE Text_IO.Get_Line
(file file_type,
item OUT VARCHAR2);
Parameter | Description |
---|---|
file | A variable that specifies an open file. |
item | A variable used to hold the next line read. |
TEXT_IO.GET_LINE() does not handle multibyte encoded data. You will see text appended with squares when there is multibye encoded data.
/*
** Open a file and read the first line
** into linebuf.
*/
declare
in_file Text_IO.File_Type;
linebuf VARCHAR2(80);
begin
in_file := Text_IO.Fopen('salary.txt', 'r');
Text_IO.Get_Line(in_file,linebuf);
end;