DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Exceptions within a loop

  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Exceptions within a loop

    Basically I am going through each row in a table like this:
    CREATE OR REPLACE PROCEDURE
    testProc
    IS


    CURSOR hd_cur IS
    SELECT *
    FROM table;

    BEGIN
    FOR hd_rec IN hd_cur
    LOOP

    IF something
    THEN
    RAISE exception



    EXCEPTIONS


    END LOOP;


    END;

    Within the loop there will be some if statements and i want to raise an exception in some cases. But I need to pass all the values in the row to exceptions so i can insert them into another table. Is it possible to do something like above?

    Also I want to loop to continue to the next row after as well. Any ideas?


    Any help appreciated!

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    I don't see the point of raising an exception that you will trap in the same block. Why not just put your "exception" processing in the if?
    Last edited by DaPi; 03-27-2004 at 07:50 AM.

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    Code:
    
    begin
       for i in (select blah blah)
       loop
          begin
             if ... then
                blah blah
             end if;
          exception
             when .... then
                blah blah
          end;
       end loop;
    end;
    /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width