Solved

Loop doesnot EXIT on condition

Posted on 2006-06-28
4
1,554 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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

772 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