Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> PL/SQL and multiple UPDATE
Hello newsgroup,
I wrote a PL/SQL procedure to execute multiple UPDATE statements (code see below), which functions well. However, does anyone have an idea how to use a LOOP structure (and/or some kind of associative ARRAY) in order to reduce the size of code (and the redunancy), especially when there are more than 10 UPDATE statements to be executed?
Thanks for your help!
Eckhard
PROCEDURE proc(parameter_list)
IS
CURSOR update_cur IS SELECT a,b,c,d FROM t_table WHERE column=v_in FOR UPDATE; update_rec update_cur%ROWTYPE; BEGIN OPEN update_cur; FETCH update_cur INTO update_rec; UPDATE t_table SET a=v_1_in WHERE CURRENT OF update_cur; UPDATE t_table SET b=v_2_in WHERE CURRENT OF update_cur; UPDATE t_table SET c=v_3_in WHERE CURRENT OF update_cur; UPDATE t_table SET d=v_4_in WHERE CURRENT OF update_cur; CLOSE update_cur;