Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with exception handling
On Fri, 17 Jul 1998 13:47:37 +0200, "Ivan Bajon" <ib_at_ed.dk> wrote:
>I'm trying to make a procedure resume after an exception has been raised.
>The situation is more or less like this:
>
>procedure My Proc;
>begin
> for c1rec in c1 loop
>/* c1 is my cursor */
> insert into sometable c1rec.somefield;
> commit;
> end loop;
> exception
> when others do
> insert into errortable 'Some error message';
>end;
>
>Lets say c1 yields 1000 records and that an exception occur in the 500th
>insert. How do I make it resume and do the last 500 inserts after handling
>the exception?
>
>Any help appreciated.
>- Ivan Bajon NOCP (Not Oracle Certified Professional)
>
>
No problem Ivan, You just need to include the exception handller in a
discrete block ie.
CURSOR c1 IS
SELECT ename
FROM emps;
v_ename varchar2(20);
BEGIN
FOR c1rec IN c1 LOOP
BEGIN v_ename := c1rec.ename; Message(' name = '||v_ename ); EXCEPTION When Others Then Message( 'when others'); END;
![]() |
![]() |