Solved

pl/sql varrays

Posted on 2003-11-05
7
990 Views
Last Modified: 2011-09-20
Hi all,

I have an object with its own functions and a varray type variable:


CREATE OR REPLACE TYPE idarray IS VARRAY(100000000) OF INTEGER;
/

CREATE OR REPLACE TYPE my_obj AS OBJECT
(
 ids idarray,
 ...
 STATIC FUNCTION ODCIIndexStart(sctx in out my_obj) RETURN NUMBER,
 MEMBER FUNCTION ODCIIndexFetch(self IN OUT my_obj) RETURN NUMBER
 ...
);
/


------------------------------------------------------------------------------------
I want to load a lot of integer into an idarray array inside the ODCIIndexStart function then give the array to the ODCIIndexFetch function as a parameter. As I realized if the size of the array is big it takes too much time while the array gets to the ODCIIndexFetch function.
My object's and the ODCIIndexStart and ODCIIndexFetch functions' interfaces cannot be changed thus I have to use the sctx and self parameters to "transport" the array.

Is there any solution that makes it possible to give the handler of the array (memory pointer, etc) as parameter not the whole array?

ps. I cannot use DML functions inside my code, thus I cannot write the array into a table.

code:
----------------------------

CREATE OR REPLACE TYPE BODY jc_idxtype_im IS

STATIC FUNCTION ODCIIndexStart(sctx in out my_obj) RETURN NUMBER IS
 ida idarray := idarray();
 BEGIN
   ...
     -- loading integers into the ida array
   ...
   sctx := my_obj(ida);
   RETURN 1;
 END;

MEMBER FUNCTION ODCIIndexFetch(self IN OUT my_obj) RETURN NUMBER IS
 ida idarray := idarray();
 BEGIN
   ida := self.ids;
 END;

END;
/

thanks,
gabor
0
Comment
Question by:gatyo
7 Comments
 
LVL 2

Accepted Solution

by:
vanmeerendonk earned 63 total points
ID: 9687294
I've not a  lot of experience with objects/methods in oracle wasn't this possible using REF in combination with UTL_REF??

CREATE OR REPLACE TYPE my_obj AS OBJECT
(
 ids  REF idarray,

..
and within your  method
UTL_REF.SELECT_OBJECT(p_ref, ids)

other experts?
0
 

Expert Comment

by:Chloe_Loh
ID: 9687426
hi,

this is my first time to try to create an oracle database and can u guys give me the create database script? thank you

regards,
chloe
0
 

Author Comment

by:gatyo
ID: 9687450
thanks, looks good

In this case I have to call the my_obj() 's constructor with a REF parameter that reference to the 'ida' idarray.

How can I create a REF to a varray inside the ODCIIndexStart function?
How can I use that REF to add values to the array?

thanks

0
 
LVL 15

Assisted Solution

by:andrewst
andrewst earned 62 total points
ID: 9687543
You can use the NOCOPY option:

sctx in out NOCOPY my_obj
0
 
LVL 2

Expert Comment

by:vanmeerendonk
ID: 9693010
For adding...
something like
UTL_REF.LOCK_OBJECT(p_ref, l_object);  --> locked and selected
.. alter l_object..
UTL_REF.UPDATE_OBJECT(p_ref,l_object); --> put it back

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now