PL/SQL Block (LOOP) Comparison [message #558052] |
Tue, 19 June 2012 01:30 |
|
Is there any difference between these two statement (regarding performance)?
PROCEDURE proc1
IS
CURSOR cur1
IS
SELECT col1, col2, col3
FROM table1
WHERE col1 = :block1.text1;
BEGIN
FOR x IN cur1
LOOP
INSERT INTO table2
(col1, col2, col3
)
VALUES (x.col1, x.col2, x.col3
);
END LOOP;
END;
VS
PROCEDURE proc1
IS
BEGIN
FOR x IN (SELECT col1, col2, col3
FROM table1
WHERE col1 = :block1.text1)
LOOP
INSERT INTO table2
(col1, col2, col3
)
VALUES (x.col1, x.col2, x.col3
);
END LOOP;
END;
|
|
|
|
Re: PL/SQL Block (LOOP) Comparison [message #558058 is a reply to message #558055] |
Tue, 19 June 2012 01:45 |
|
I'm sorry for the double post..
I agree with your code but what if the result of the select statement returns more than 1 record? That's why I changed it to the second statement. I just inherit this module/program and I'm just trying to improve its codes. I'll test it and reply here the result. Thanks Littlefoot.
|
|
|
|
|