Home » SQL & PL/SQL » SQL & PL/SQL » Fetch out of Sequence error
Fetch out of Sequence error [message #4432] Sun, 08 December 2002 20:18 Go to next message
Sanket Naik
Messages: 4
Registered: December 2002
Junior Member
Hi,

I have a question regarding a cursor problem.

For crec IN cur Loop
Begin

Insert into table...

Exception
Put error in error code table
Continue with next record
End;
End Loop;

I want to continue reading next record ,even if any Insert is failed in the loop,but the cursor error Fetch out of Sequence appeared if I do as above.

Can anybody suggest ,whats the other way of handling this logic ?

Thanks,
Sanket
Re: Fetch out of Sequence error [message #4441 is a reply to message #4432] Tue, 10 December 2002 00:35 Go to previous messageGo to next message
Garima
Messages: 1
Registered: December 2002
Junior Member
Once the control comes to the exception block u cannot get it back to the cursor.
But then try before end calling a procedure or function which will insert the records in the block.
Anyways even ia m trying this if i get the solution i'll pass it on t ou
Re: Fetch out of Sequence error [message #4462 is a reply to message #4432] Wed, 11 December 2002 14:11 Go to previous message
Dhiren
Messages: 43
Registered: July 2002
Member
What you need to do is write a local exception
handler for your INSERT statement.
I am giving an example - sample code for you
which is pretty self explanatory and works fine
even if you encounter a error in the insert.
Try it out.

declare
cursor c1 is select * from emp;
begin
for c1rec in c1
loop
begin
dbms_output.put_line(c1rec.empno);
insert into abcemp (empno) values (c1rec.empno);
exception
when others then
dbms_output.put_line('Error encountered Above ');
end;
end loop;
exception
when others then
dbms_output.put_line('Error encountered ');
end;
/
Previous Topic: urgent!
Next Topic: Update - Rollback Problem
Goto Forum:
  


Current Time: Wed May 15 12:26:38 CDT 2024