cursor to Update Multiple Records
608596Sep 19 2008 — edited Sep 19 2008Hi all
Oracle forms V6
I am trying to use a cursor to update multiple rows associated with the change of a single value, the tables are related but not directly through the values I am trying to change. The form is multi-tab with a block per tab. On the first tab a value entered into a specific field is subsequerntly used in another multi-record tab when the time comes to fill this in, the value is automatically inserted, and this works fine.
If there is multiple records in the second tab then the value from the parent record will be displayed in all records in the 2nd tab because it is automatically taken from the parent record.
I am trying to use a for-loop cursor to update more than one row when the parent value is updated, at present it only updates one row, yet a message I put in cursor shows the different values being stepped through in the cursor. I don't have much experience in this area yet but it looks like the actual form cursor needs to be moved to the next record to update that as well, as you change to this tab you can see the first record being updated but not the second.
Cursor is in the when validate item on the first tab/block.
DECLARE
v_cvs_val VARCHAR2(100) := :b1.new_value;
CURSOR c_cvs IS
SELECT b2.pk, b2.oldValue
FROM T1
WHERE T1.pk = :b2.pk;
--result set of cursor is all records relating to current parent record
mcec_rec c_cvs%ROWTYPE; --declares record of cursor type
BEGIN
IF :system.record_status = 'CHANGED' AND :b2.pk IS NOT NULL THEN
OPEN c_cvs;
LOOP
FETCH c_cvs INTO mcec_rec;
:b2.oldValue := v_cvs_val;
EXIT WHEN c_cvs%NOTFOUND;
END LOOP;
CLOSE c_cvs;
END IF;
END;
Any suggestions as to where i'm going wrong would be very much appreciated.
user605593