Solved

Filling a Varray

Posted on 2003-12-03
2
955 Views
Last Modified: 2007-12-19
I need help with the TYPE Varray....

I have a parser that will send me data ....I need to grab those names from the parser and use them as parameters into a stored procedure or the parser code can call the stored procedure and pass this in as parameters...I thought something like this...

Create type target_list_t is Varrary(100) OF Varchar2(20);
Create OR replace procedure Get_Targets ( list_in IN target_list_t)
IS
Begin
FORALL listnum IN list_in..First list_in.LAST
   Select * from tABle where thing = list_in ( listnum);
END;

I have a PL/SQL book but I am unclear on HOW the arrary is filled....do I have to initialize EACH entry from 0-99?

Do I need an OUT statement?  To output the select statement results?
Would it be better to just have a list of parameters in the create procedure and then check to see if they are null ..if not create a select statment? Again do I need an OUT for the results?

I dont have access right now to any data so Im writing kinda blindly without being able to test on a system....
0
Comment
Question by:Tereza
2 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 250 total points
ID: 9869475
The best way to do this is pass the comma-delimited string from your application to your stored procedure, inside which you have to code to parse the string, and initializ your array one by one in a loop.

don't expect to pass in a parameter AS ARRAY type from your application because they don't comply with ARRAY type in PL/SQL.

if you want your select results as output , of course you need a OUT parameter , to be more specific, a CURSOR TYPE parameter as OUT .

the signature of the stored procedure will look like this:

Create or replace package my_types AS
TYPE g_cursor_type IS REF CURSOR;
end;

Create OR replace procedure Get_Targets ( p_in_string IN VARCHAR2, p_cursor_out OUT my_types.g_cursor_type)
IS

---Processing and parsing the comma-delimited string p_in_string
---LOOP initialized v_array
--open the cursor with the select statement
end;
/
0
 

Author Comment

by:Tereza
ID: 9869494
thanks....;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

749 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