473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Collections in PL/SQL

Hi All,

I have a Stored Procedure in which i have a for loop .In this loop i have a select statement and the returned row i am storing in a temporary physical table like

for cntr in 1..count loop
insert into temp(col1,col2,col3)
select col1,col2,col3 from table connect by id1=id start with id=cntr;
End loop;

And in the front end i am reading values from that temp table.
But this is taking long time to run when executed.
I googled abt this and found out many about Oracle Collections but i have never used this. Can any body help me out .
Jun 6 '08 #1
8 1771
debasisdas
8,127 Expert 4TB
Try using the following steps.

1.create the procedure as part of a package.
2.declare a ref cursor inside a package.
3.use the ref cursor as the out parameter of the procedure.
Jun 6 '08 #2
Hi,

Its confusing. Du want me to output refcursor from SP or Package? I have never used package. If possible can you wite me a sample one and how to call it.

Thanks
Jun 6 '08 #3
debasisdas
8,127 Expert 4TB
please check for some related articles in the HowTo section of the forum.
Jun 9 '08 #4
amitpatel66
2,367 Expert 2GB
Why are you doing a select inside FOR LOOP?
Why dont you insert all the records in the loop,commit and then SELECT JUST ONCE?
Jun 9 '08 #5
Why are you doing a select inside FOR LOOP?
Why dont you insert all the records in the loop,commit and then SELECT JUST ONCE?
Hi Amit,

I am doing
for i=1..count loop
Insert into table(col1,col2,col3)
select c1,c2,c3 from table where id=i
End loop
So i get 1 row for each iteration in for loop which i am iserting in a table. After i am done with for loop ,I have opened a ref_cursor forthe table in which i have inserted and returning that Ref_cursor back.
But this is very slow since there its doing a insert to a table. I want to improve its performance. I think collections is the only way to make it work fast. I have never used collections.
Jun 9 '08 #6
amitpatel66
2,367 Expert 2GB
you said that you are using ref cursor for that table after for loop and returning that ref cursor as out parameter...then what is the use of this SELECT statement inside the loop:

select c1,c2,c3 from table where id=i ??
Jun 10 '08 #7
you said that you are using ref cursor for that table after for loop and returning that ref cursor as out parameter...then what is the use of this SELECT statement inside the loop:

select c1,c2,c3 from table where id=i ??
I get one row for each iteration. I am inserting that row in temporory table. After for loop, i open cursor for that temporory table and return it.
Jun 12 '08 #8
amitpatel66
2,367 Expert 2GB
I get one row for each iteration. I am inserting that row in temporory table. After for loop, i open cursor for that temporory table and return it.
Why dont to insert all records first and then select from that table instead of selecting one by one after insert.
Jun 24 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: a | last post by:
Is there a performance hit if I have many "using" statements that are unnecessary? For example: using System.Collections; when nowhere in my code I'm using System.Collections namespace. I'm...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
2
by: ESPNSTI | last post by:
Hi, I'm trying to use a generics dictionary with a key class that implements and needs IComparable<>. However when I attempt to use the dictionary, it doesn't appear to use the IComparable<> to...
10
by: jcc | last post by:
Hi guys, I'm a newbie to C#. My Visual Studio 2005 failed to compile the following code with error as 'HelloWorld.A' does not implement interface member...
14
by: Steve Teeples | last post by:
I don't understand why I cannot use a property to modify data within a struct. Can someone tell me why I get the error "Cannot modify the return value of "myData.TheData" because it is not a...
1
by: Thiero | last post by:
Hi I posted s thread but did have any reply, I am a new programmer and really wants someone to help me on how to use TreeMap for this code cos I want to it to be able to handle the options from 6...
1
by: Joachim | last post by:
Can you import namespaces into an ASP .NET 2005 web site project C# file? For instance, when I run using System.Collections.Generic; public partial class _Default : System.Web.UI.Page, IMainView...
6
by: Mark Rae | last post by:
Hi, I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses ActiveDirectory a great deal, and I'm trying to use the new System.Collections.Generic namespace where possible,...
3
by: Marco Shaw | last post by:
I've got some C# code to create a custom PowerShell cmdlet with these statements: .... using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; .... ...
3
by: Tony Johansson | last post by:
Hello! You can set target Module for AttributeUsage. I just wonder what does it mean with module ? //Tony
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.