Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> PL/SQL and multiple UPDATE

PL/SQL and multiple UPDATE

From: Eckhard Kirschning <kirschni_at_uke.uni-hamburg.de>
Date: 2000/04/23
Message-ID: <3902ED9F.243141B0@uke.uni-hamburg.de>#1/1

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;

END proc; Received on Sun Apr 23 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US