Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Procedure using utl_file.fopen

user10698496Nov 8 2011 — edited Nov 11 2011
Hi ,
I want to open a file ,read it line by line and if i find one particular word i want to display the whole line.
I tried writing a procedure but not getting desired output.

DECLARE
x utl_file.file_type;
y varchar2(200);
BEGIN
x:= utl_file.fopen('TRACE1',DB_ora_111_trc.txt','R');
LOOP
BEGIN

UTL_FILE.GET_LINE(x,y);
if x='select' then
dbms_output.put_line(x);
end if;

EXCEPTION
WHEN NO_DATA_FOUND THEN EXIT ;
END;
END LOOP;
utl_file.fclose(x);
END;
/

Here i am opening a tkprof file and trying to grep for select word and if it is found,display the whole select query.The above is not showing any output.Kindly assist me since i am new to coding.

Thanks
This post has been answered by BluShadow on Nov 10 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2011
Added on Nov 8 2011
15 comments
589 views