Creating cursors inside a For Loop
802484Oct 2 2010 — edited Oct 3 2010Dear Gurus,
I have an issue where I need to create a cursor, and use the fields from that cursor, to create another cursor, and perform actions in the second cursor.
Below is my main cursor:
===========================================================================
DECLARE
v_DMDGROUP dfu.DMDGROUP%TYPE;
v_beforevalue udt_master_updates.udc_before_value%TYPE;
CURSOR curtrackdfuchanges
IS
SELECT *
FROM udt_master_updates
WHERE udc_data_element IN
('RESTERRITORY', 'RESREGION', 'RESAREA', 'COMMTERRITORY',
'COMMREGION', 'COMMAREA', 'COMPTERRITORY', 'COMPREGION',
'COMPAREA')
AND udc_action = 'CHANGED'
AND udc_interface = 'DMDGROUP';
recdfu curtrackdfuchanges%ROWTYPE;
v_sql VARCHAR2 (300);
BEGIN
OPEN curtrackdfuchanges;
LOOP
FETCH curtrackdfuchanges
INTO recdfu;
===========================================================================
Now based on this cursor's output, I need to create a new cursor which will extract three fields of a table (DFU) which are primary keys. But this action needs to be performed inside a FOR loop, as it needs to be done for many other rows for which this condition is true.
Is it posible to create a cursor inside a FOR Loop ? If yes, does anyone have a syntax for a code which has a top level cursor, and a cursor inside a for loop with the outputs of the first cursor?
Thanks in advance for your reply.
With Regards,
Swapneel Kale