Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Issuing DELETE Statements in a Loop

DROP TABLE parts1 CASCADE CONSTRAINTS PURGE;

CREATE TABLE parts1 (
pnum INTEGER,
pname VARCHAR2(15));


DROP
TABLE parts2 CASCADE CONSTRAINTS PURGE;

CREATE TABLE parts2 (
pnum INTEGER,
pname VARCHAR2(15));


DECLARE

TYPE numtab IS TABLE OF parts1.pnum%TYPE INDEX BY PLS_INTEGER;
TYPE nametab IS TABLE OF parts1.pname%TYPE INDEX BY PLS_INTEGER;
pnums NUMTAB;
pnames NAMETAB;
iterations CONSTANT PLS_INTEGER := 500;
t1 INTEGER;
t2 INTEGER;
t3 INTEGER;
BEGIN
FOR j IN 1.. iterations LOOP -- load index-by tables
Pnums(j) := j;
Pnames(j) := 'Part No. '
||To_char(j);
END LOOP;
t1 := dbms_utility.get_time;
FOR i IN 1.. iterations LOOP -- use FOR loop
INSERT INTO parts1
VALUES (Pnums(i),
Pnames(i));
END LOOP;
t2 := dbms_utility.get_time;
FORALL i IN 1..iterations -- use FORALL statement
INSERT INTO parts2
VALUES (Pnums(i),
Pnames(i));
t3 := dbms_utility.get_time;
dbms_output.Put_line('Execution Time (secs)');
dbms_output.Put_line('---------------------');
dbms_output.Put_line('FOR loop: '
||To_char((t2
- t1)
/ 100));
dbms_output.Put_line('FORALL: '
||To_char((t3
- t2)
/ 100));
COMMIT;
END;
/



OUTPUT:-

Execution Time (secs)
---------------------
FOR loop: .03
FORALL: 0

PL/SQL procedure successfully completed.

Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-