Professional Documents
Culture Documents
Steven Feuerstein
steven@stevenfeuerstein.com
www.StevenFeuerstein.com
www.PLSQLChallenge.com
Quick Reminders
Download code and PowerPoint documents
from www.ToadWorld.com/SF (aka, "PL/SQL
Obsession").
Make sure you are comfortable with the
material covered in the previous lesson in this
series.
Introduction to Bulk Processing
Also: make sure you know about and can work
with collections.
Copyright 2010 Feuerstein and Associates
Page 2
Page 3
Page 4
Page 5
DECLARE
TYPE employees_aat IS TABLE OF
employees%ROWTYPE;
l_employees employees_aat;
BEGIN
SELECT *
BULK COLLECT INTO l_employees
FROM employees;
bulkcoll.sql
bulkcollect.tst
Page 7
process_emps (emps);
END LOOP;
CLOSE emps_in_dept_cur;
END bulk_with_limit;
bulklimit.sql
Copyright 2010 Feuerstein and Associates
Page 8
Page 9
Page 10
Page 11
Conclusions
BULK COLLECT improves performance of
queries that retrieve more than one row.
Use the LIMIT clause to avoid excessive PGA
memory consumption.
Leave it to the optimizer to speed up "read
only" cursor FOR loops.
Page 12
Next Steps
Download the demo.zip if you have not
already (www.ToadWorld.com/SF).
Run the sample code yourself to better
understand the features and techniques.
Page 13