| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Stored Procedure Help
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;
![]() |
![]() |