Hi all,
I've been told that inserting data into a table using a cursor (see example below) is very
inefficient and will take long time to process. I think this is the example that was given.
If this is true, why? and what is a better way
of doing it?
Thanks
E
Example
DECLARE
CURSOR testCur IS select * from emp;
myRec testCur%ROWTYPE;
BEGIN
OPEN testCur;
LOOP
FETCH testCur INTO myRec;
EXIT WHEN testCur%NOTFOUND;
INSERT INTO emp2 VALUES (myRec.empno);
END LOOP;
CLOSE testCur;
END;
I've been told that inserting data into a table using a cursor (see example below) is very
inefficient and will take long time to process. I think this is the example that was given.
If this is true, why? and what is a better way
of doing it?
Thanks
E
Example
DECLARE
CURSOR testCur IS select * from emp;
myRec testCur%ROWTYPE;
BEGIN
OPEN testCur;
LOOP
FETCH testCur INTO myRec;
EXIT WHEN testCur%NOTFOUND;
INSERT INTO emp2 VALUES (myRec.empno);
END LOOP;
CLOSE testCur;
END;