Hi all,

I'm trying to run the statement below but I continue to get the error messages that the Rowid was not declared and v_trans is used incorrectly. This code the trans_no field with values starting from the maximum trans_novalue.

Can someone please help me debug/rewrite this update code?

Thanks


DECLARE
CURSOR Upd_trans_no IS
SELECT trans_no,row_id from temp_reimb_control;
V_counter_num pls_integer := 0;

BEGIN

FOR v_trans in Upd_trans_no LOOP
-- update every record with null trans_no values
IF v_trans.trans_no is NULL THEN
-- Increment transaction counter
v_counter_num := v_counter_num + 1;
UPDATE temp_reimb_control
SET trans_no = (select max(trans_no) + v_counter_num from temp_reimb_control)
WHERE row_id = v_trans.ROW_ID;

END IF;
END LOOP;
commit;
END;
/