I'm new in pl/sql and maybe it is sounds silly,but I have a question. By Using utl_file,I'm reading a text file. But my text file contains blank spaces between rows, and I need to continue to read all content even after that blank space. below I displayed my code that I used, and the template of my text file.
DECLARE
V1 VARCHAR2(200);
F1 UTL_FILE.FILE_TYPE;
BEGIN
F1 := UTL_FILE.FOPEN('directory','text.txt','R');
Loop
BEGIN
UTL_FILE.GET_LINE(F1,V1);
dbms_output.put_line(V1);
EXCEPTION WHEN No_Data_Found THEN EXIT; END;
end loop;
dbms_output.put_line(emptylines);
UTL_FILE.FCLOSE(F1);
END;
/
Template of my text file
alarma2
alarma2
alarma2
alarma3
alarma3
alarma3
alarma3
Any idea how I can make to display all file content, not just until blank space?
Maybe you could try this:
...
Loop
BEGIN
UTL_FILE.GET_LINE(F1,V1);
IF (TRIM(V1) is not null) AND ((TRIM(V1) <> CHR(10)) OR (TRIM(V1) <> CHR(13))) THEN
dbms_output.put_line(V1);
END IF;
...
I don't know what you mean with dbms_output.put_line(emptylines);
so I didn't care a bout it :). Maybe you could check if the line you are processing is not empty and hasn't a carriage return (CHR(13)) or line feed (CHR(10)) and with this you could determinate which lines contain data and which not. Hope this help!!!.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.