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 -> Stored Procedure Help

Stored Procedure Help

From: Aaron Rouse <aaron_rouse_at_yahoo.com>
Date: 13 Feb 2003 17:27:24 -0800
Message-ID: <a57b6daf.0302131727.69566de5@posting.google.com>


I am attempting to make a store procedure that will loop over the data in my table and prepend some zeros to one columns value, convert it to a varchar and then insert the new value in another table. Upon running the script I created, my client(Toad) ends up just hanging and I eventually end up just ending the task on it. The record set I am looping over has 23,411 records, is the procedure just inefficient for that many rows or is their a flaw in the syntax I used in creating it?

CREATE OR REPLACE procedure SP_SLB_SAPMERGE AS

	   BEGIN
	   	FOR i IN SAPORG LOOP
		   IF LENGTH(i.NO_EMP_NUSER3) = 1 THEN
		     SAPORG_NEW := '0000000' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 2 THEN
		     SAPORG_NEW := '000000' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 3 THEN
		     SAPORG_NEW := '00000' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 4 THEN
		     SAPORG_NEW := '0000' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 5 THEN
		     SAPORG_NEW := '000' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 6 THEN
		     SAPORG_NEW := '00' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 7 THEN
		     SAPORG_NEW := '0' || to_char(i.NO_EMP_NUSER3);
		   ELSIF LENGTH(i.NO_EMP_NUSER3) = 8 THEN
		     SAPORG_NEW := to_char(i.NO_EMP_NUSER3);
		   END IF;
			
                   -- UPDATE Employees Table
		   UPDATE EMPLOYEES
		   SET CD_LOC = SAPORG_NEW
		   WHERE NO_EMP = i.NO_EMP;

		 END LOOP;
		 COMMIT;

END SP_SLB_SAPMERGE;
/ Received on Thu Feb 13 2003 - 19:27:24 CST

Original text of this message

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