I need to have stored procedure where I can run multiple cursors.
Loop over each cursor and then do some operation on each row.
This way I will have the desired result from these cursors. Result of such multiple cursors then needs to be union with some other rows and then filtered out and return those rows finally from the proc.
Please note that each cusror and another queries will have same columns.
I am not sure how to do this in the oracle.
Please help me out.
create or replace PROCEDURE test_proc
(
-- some inputs
hc_cursor OUT SYS_REFCURSOR
)
IS
cursor cursor_one is
SELECT * FROM table_one ;
BEGIN
FOR current_row in cursor_one
loop
-- do some modification on each row and return each modified row
end loop;
cursor cursor_two is
SELECT * FROM table_one ;
BEGIN
FOR current_row in cursor_two
loop
-- do some modification on each row and return each modified row
-- append to result from first cursor
end loop;
-- union results from both these cusrors with some another query
-- now filter these records on some criterais
-- return finally
END;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…