Exception handlers in cursor loops [message #370617] |
Sat, 08 January 2000 04:21 |
Srilatha Ramachandran
Messages: 3 Registered: January 2000
|
Junior Member |
|
|
I am trying to use exception handler within a cursor loop for ZERO_DIVIDE error. Once the exception is raised the loop statement does not continue but I receive an error ORA-1002- fetch out of sequence. How do I continue with the loop after the exception is raised
|
|
|
Re: Exception handlers in cursor loops [message #370618 is a reply to message #370617] |
Mon, 10 January 2000 11:04 |
hmg
Messages: 40 Registered: March 1999
|
Member |
|
|
try this
set serveroutput on
declare
v_result number;
begin
for i in 1..100 loop
begin
v_result := i / mod( i, 10);
exception
when zero_divide then
dbms_output.put_line('divide by zero for i = ' || i);
end;
end loop;
end;
/
|
|
|
|
Re: Exception handlers in cursor loops [message #370625 is a reply to message #370621] |
Tue, 11 January 2000 10:10 |
Srilatha Ramachandran
Messages: 3 Registered: January 2000
|
Junior Member |
|
|
Thanks for your reply, i tried out the above with a while loop but does not work out
My code flows like-
--------------------------------
open c1;
LOOP
Fetch c1 into v_name,v_name1;
BEGIN
...code...
EXCEPTION
When Zero_Divide then
v_no:=0;
END ;
Insert into table1 values(v_name,v_name1,v_no);
Commit;
END LOOP;
-------------------------------------
It is at the fetch point the error occurs - fetch out of sequence.
The fetch does not get advanced to the next row in the table.
|
|
|
|
|
Re: Exception handlers in cursor loops [message #371333 is a reply to message #370617] |
Wed, 04 October 2000 07:00 |
sathish kumar
Messages: 1 Registered: October 2000
|
Junior Member |
|
|
This error occurs when the FETCH statemnet perform more then the records in the table . This error is done when the statement is written for
CURSOR FOR UPDATE,so this is happen when the fetch statement is looking for a record when the updation is over .To avoid this pls write a select statement before the cursor update the table.This may avoid reducancy and accurate.
Pls Try this and mail me if u can ......
Looking forward for ur kind attention towards my query..
|
|
|