Académique Documents
Professionnel Documents
Culture Documents
HOME
y o u
w a n t
CONTACT
t o
m e e t
y o u r
f e l l o wF a Oc re ab c o l oe k
A p p s
C o n s u
Home PL/SQL
WsB
hiaU
tLKCOLLECT?HowandWhydoweneed
ou
t?tsei
31 DECEMBER 2014
229 VIEWS
0 COMMENTS
Recent Posts
Before understanding about BULK COLLECT, lets see how a PL/SQL code is executed. Oracle uses two
engines to process PL/SQL code. All procedural code is handled by the PL/SQL engine while all SQL is
handled by the SQL engine. When ever there is a need to process an SQL statement, a context switch
happens between PL/SQL and SQL engines.
STAY CONNECTED
Subscribe FREE updates on your Email | RSS
Enter your email address
Subscribe
My Sponsers~!
Image a cursor with a SELECT statement which retrieves 1000 rows, in such scenario a context switch
will happen for 1000 times which consumes lot of CPU resources and leads to a performance issue.
BULK COLLECT is one of the way to solve this problem.
BULK COLLECT is one of the way of fetching bulk collection of data. With Oracle bulk collect, the
PL/SQL engine tells the SQL engine to collect many rows at once and place them into a collection.
During an Oracle bulk collect, the SQL engine retrieves all the rows and loads them into the collection
and switches back to the PL/SQL engine. When rows are retrieved using Oracle bulk collect, context
switch happens only once. The larger the number of rows you would like to collect with Oracle
bulk collect, the more performance improvement you will see using an Oracle bulk collect.
Example
In this example, lets use BULK COLLECT to fetch information of all the applications present in an EBS
instance.
converted by W eb2PDFConvert.com
1 DECLARE
2
TYPE xx_rec IS RECORD (
3
col1 fnd_application.APPLICATION_ID%TYPE,
4
col2 fnd_application.APPLICATION_SHORT_NAME%TYPE,
5
col3 fnd_application.PRODUCT_CODE%TYPE,
6
col4 fnd_application.BASEPATH%TYPE
7
); --Record Type
8
9
TYPE xx_tab IS TABLE OF xx_rec
10
INDEX BY BINARY_INTEGER; --Table Type
11
12
v_tab xx_tab; --This is a type of Collection
13
14
-15
--Cursor to list all applications in EBS instance
16
-17
CURSOR cur
18
IS
19
SELECT application_id, application_short_name, product_code, basepath
20
FROM fnd_application;
21 BEGIN
22
23
OPEN cur;
24
25
FETCH cur
26
BULK COLLECT INTO v_tab; --BULK COLLECT usage
27
28
CLOSE cur;
29
30
FOR l_index IN v_tab.FIRST .. v_tab.COUNT
31
LOOP
32
DBMS_OUTPUT.put_line ( v_tab (l_index).col1
33
|| ' '
34
|| v_tab (l_index).col2
35
|| ' '
36
|| v_tab (l_index).col3
37
|| ' '
38
|| v_tab (l_index).col4
39
);
40
END LOOP;
41 END;
Tag Cloud
Categories
Alerts (1)
AOL and SYSADMIN
(29)
AOL SQL Scripts
(20)
APIs (3)
FNDLOAD download
Business Events
FNDLOAD upload
(2)
FND_DEVELOPER_MODE
FND_DEVELOPER_MODE
Custom PLL (1)
in routine
HRMS (4)
Interview
Questions (5)
How to port reports
Inventory (7)
from one instance to
another HRMS Profile
iRecruitment (1)
Options iStore items
iStore (1)
not available ldt files
OAF (4)
Line Status Flow MOAC
Move Transaction
Oracle Apps Basics
Manager O2C C ycle
(16)
Oracle Logo Pending
Oracle Learning
Resource Transactions
Management (4)
personalization pl/sql
procedures porting
Oracle SQL (13)
reports profileoption
Order Management
Profile options Reports
(11)
Retcode Sales Order
Personalizations
line Status Flow Ship
Note: Remember that collections are held in memory, so doing a bulk collect from a large query could
(4)
C onfirm button greyed
occupy most of your memory considerably leading to performance problem. Instead you can limit the
Shipping Transactions
PL/SQL (10)
form table suffix
rows returned using the LIMIT clause and move through the data processing smaller chunks. Below is
WIP_C OST_TXN_INTERFAC E Profile Options (5)
_A _AC N _ALL _AVN
an example of usage of LIMIT clause
Purchasing (3)
_B _F _S _TL _V _VL
Receivables (1)
OPEN cur;
Reports (2)
COPYRIGHT
Security (1)
FETCH cur
Shipping Execution
BULK COLLECT INTO v_tab LIMIT 100; --limiting BULK COLLECT to 100 records each per a context switch
(2)
This w ork is licensed
under a Creative
Unix / Shell Scripts
CLOSE cur;
Commons(1)
NonCommercial 2.5
W IP Jobs (1)
License.
W orkflow s (12)
XMLP (9)
FNDLOAD
fnd_request.submit_reques
converted by W eb2PDFConvert.com
EBS Reporting
Webinar
Join Us for Our Oracle E-Business
Suite Reporting Tool Webinar.
WOW! Did you like this post? We'll send more interesting posts like What is BULK COLLECT? How
and Why do we need to use it? to you!
Enter your Email Address:
Enter your email address Subscribe Me!
0 Comments
Login
OracleAppsDNA
Share Favorite
Sort by Oldest
Subscribe
Recent Posts
W hat is the role of a Functional Consultant
in Support and Implementation Project?
API approach to find On Hand Quantity of
an Item
W hat is the Difference betw een Available
to Reserve & Available to Transact
W hat is BULK COLLECT? How and W hy do
w e need to use it?
Frequently asked SQL Interview Questions
on EMP, DEPT table
Top PL/SQL Interview Questions w ith
Answ ers
W hy cant w e use SQLERRM and SQLCODE
in INSERT Statement?
FND_GLOBAL and FND_PROFILE: Import
List of System Global values
Privacy
Most Viewed
[Decrypting User Passw ord]How to find
passw ord of a User in Oracle Apps R12? 12,349 view s
Top PL/SQL Interview Questions w ith
Answ ers - 8,638 view s
SQL Query to list Active Responsibilities of
a Active User - 8,596 view s
Useful Information about W orkflow
Background Process Concurrent Program 8,126 view s
Order to Cash Technical Flow - 7,502
view s
How costing is performed on Inventory
Material Transactions - 7,331 view s
Information about Oracle APIs and How to
find APIs of Oracle Modules? - 7,103 view s
Recent Comments
Recent Comments
Shashi Kiran One more reason for
backorder: In an Oracle W arehouse
Management enabled organization,
you must specify the staging subinventory
and locator w ithin the pick release criteria.
If you fail to specify...
11 Reasons for a Sales O rder to get
Back ordered! 4 days ago
converted by W eb2PDFConvert.com
OracleAppsDNA
2014 OracleAppsDNA. Opinions expressed here are strictly those of the ow ner, Shailender
Thallam, and those of the commenters. Articles cannot be reproduced w ithout permission from the
author.
converted by W eb2PDFConvert.com