0

Hi guys,

Both cursor works if i don't use them in one Stored procedure. Both cursors return TRUE for(cursor_x%found). But, insert into process doen't work in cursor_1. Is there any structure problem?

Thanks

CREATE OR REPLACE PROCEDURE ADD_RENTAL_SP 
IS

-- cursor1
CURSOR cursor_1 IS 
SELECT ......
rec1 VARCHAR(15);
-- cursor2
CURSOR cursor_2 IS 
SELECT ......
rec2 VARCHAR(15);

BEGIN

OPEN cursor_2;
LOOP
FETCH cursor_2 INTO rec2;
IF ( cursor_2%found ) THEN
  INSERT INTO .....
    ----
    OPEN cursor_1;
    LOOP
    FETCH cursor_1 INTO rec1;
      IF ( cursor_1%found ) THEN
        INSERT INTO ...
        EXIT WHEN cursor_1%found;
      END IF;
    END LOOP;
    CLOSE cursor_1;
    ----
  EXIT WHEN cursor_2%found;
END IF;
END LOOP;

COMMIT;
CLOSE cursor_2;
END;
1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by veledrom
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.