Solved

Loop doesnot EXIT on condition

Posted on 2006-06-28
4
1,551 Views
Last Modified: 2012-08-14
F11 UTL_FILE.FILE_TYPE;
s1 varchar2(200);

LOOP

      utl_file.get_line(F11,s1);
      IF s1 IS NULL THEN
      EXIT;
      else
dbms_output.put_line(s1);

end if;
end loop;

This loop doesnot EXIT when s is NULL it countinue and throw error
ORA-01403: no data found
ORA-06512: at "SYS.UTL_FILE", line 98
ORA-06512: at "SYS.UTL_FILE", line 656

It is very urgent please tell me the solution data file is as follows


"Ctd","DOC1","COE:  CLOSE"
"Ctd","DOC2","X"
"Ctd","DOC3","red"
"Ctd",1/2/1990,17.24
0
Comment
Question by:avi_ny
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
sathyagiri earned 500 total points
ID: 17006233
Use this
F11 UTL_FILE.FILE_TYPE;
s1 varchar2(200);

LOOP
begin
  utl_file.get_line(F11,s1);
  dbms_output.put_line(s1);
exception
  when no_data_found then
  exit;
end;
end if;
end loop;

0
 
LVL 9

Expert Comment

by:neo9414
ID: 17006324
remove the end if from your pl/sql

it should be

F11 UTL_FILE.FILE_TYPE;
s1 varchar2(200);

LOOP
begin
  utl_file.get_line(F11,s1);
  dbms_output.put_line(s1);
exception
  when no_data_found then
  exit;
end;
end loop;

0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17006341
oops i made a typo.
0
 
LVL 47

Expert Comment

by:schwertner
ID: 17007294
F11 UTL_FILE.FILE_TYPE;
s1 varchar2(200);

LOOP
      s1 := NULL;
      utl_file.get_line(F11,s1);
      exit when s1 IS NULL;
      dbms_output.put_line(s1);
 
end loop;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now