How to use cursor in oracle stored procedure
create or replace PROCEDURE sp_myprocedure(p_1 IN t1.c1%Type,
p_2 IN t1.c2%Type,
p_3 IN t3.c3%Type)
AS
BEGIN
DECLARE
v_myvariable char(7);
CURSOR crs_my_cursor IS
select * from mytable1;
BEGIN
IF (NOT crs_my_cursor%ISOPEN) THEN -- IF 1
OPEN crs_my_cursor;
END IF;
FETCH crs_my_cursor into v_my_variable;
WHILE (crs_my_cursor%FOUND) LOOP
BEGIN -- begin 2
null;
----START WORKING YOUR CODE HERE..
END;
FETCH crs_my_cursor into v_my_variable;
END LOOP;
CLOSE crs_my_cursor;
EXCEPTION
when others then
rollback;
END;
END sp_myprocedure;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment