Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some searching around, I found the answer to my own problem. Say your varray type was called varchar_pair_array and the objects stored in this array were called varchar_pair_object. varchar_pair_object is a simple object that has two varchars as it's members.</p> <p>Here is the code for executing a proc that takes in a varray of varchar_pair_object (s):</p> <pre><code>DECLARE RetVal SYS_REFCURSOR; a_simplevalue VARCHAR2(200); another_simplevalue VARCHAR2(200); my_array_of_varchar_pairs VARCHAR_PAIR_ARRAY; -- assume varchar_pair_array is defined somewhere else my_obj VARCHAR_PAIR_OBJECT; -- assume varchar_pair_object is defined somewhere else my_other_obj VARCHAR_PAIR_OBJECT; BEGIN a_simplevalue := 'hello'; another_simplevalue := 'there'; my_obj := VARCHAR_PAIR_OBJECT('nice to meet you', 'greetings'); my_other_obj := VARCHAR_PAIR_OBJECT('goodbye', 'ciao'); my_array_of_varchar_pairs := VARCHAR_PAIR_ARRAY(); my_array_of_varchar_pairs.EXTEND(2); -- this should be the number of objects you plan to put into the array my_array_of_varchar_pairs(1) := my_obj; my_array_of_varchar_pairs(2) := my_other_obj; RetVal := my_function ( a_simplevalue, another_simplevalue, my_array_of_varchar_pairs); -- assuming your array takes two varchars and one array of VARCHAR_PAIR_OBJECT (s) :to_grid := RetVal; END; </code></pre> <p>Copy paste this code in TOAD's sql editor and change it to adapt to your function and types and hit F9. TOAD will ask you the type of the :to_grid variable. Select cursor (assuming your function returns a ref cursor) and hit enter. TOAD will bind the result set to a data grid. </p> <p>Links that helped me:</p> <p><a href="http://www.smart-soft.co.uk/Oracle/oracle-plsql-tutorial-part-11.htm" rel="noreferrer">http://www.smart-soft.co.uk/Oracle/oracle-plsql-tutorial-part-11.htm</a> (good tutorial on collections) <a href="http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/10_objs.htm#1972" rel="noreferrer">http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/10_objs.htm#1972</a> (especially useful in this case is the section on declaring and initializing objects)</p> <p>With very little change the same can be done with a procedure.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload