update or delete record in a table inside cursor for loop
265441Aug 18 2010 — edited Aug 18 2010I have a cursor for loop and in the midst of the loop I want to update or delete a record. I"m not sure how to do that inside a for cursor loop. Below is the code and in comments I have were the update or delete should occur
FOR do_rec IN
( SELECT *
FROM DUE_OUT_STG
WHERE DUE_OUT_STG.ITEM_NO = v_item_no
ORDER BY DUE_OUT_STG.DDATE
)
LOOP
EXIT WHEN v_back_order <= 0;
IF working_qty >= do_rec.qty THEN
dbms_output.put_line ('full release');
--write DR to CRAM
--write RESDMD
IF v_back_order > do_rec.qty THEN
v_back_order := v_back_order - do_rec.qty;
ELSE
v_back_order := 0;
END IF;
-- working_qty := working_qty - do_rec.qty probably need to use variable instead of working_qty;
-- DELETE The record in due_out_stg
ELSE
--write DR to CRAM
-- write RESDMD
--update due_out_staging record changes the qty
null;
END IF;
dbms_output.put_line ('Inside procedure ' || ' ' || do_rec.DDATE || ' ' );
END LOOP;
Edited by: mlojan on Aug 18, 2010 7:22 AM