How do you "Instantiate" a Nested Table from within a FUNCTION?

, I managed to compile and create the FUNCTION.
But when I invoked it,
ORA-06531: Reference to uninitialized collection
ORA-06512: at "DEV.SPGETPARENTSTABLE", line ...
I think I need to somehow *"Instantiate"* the Nested Table and I didn't:
CREATE OR REPLACE FUNCTION spGetParentsTable
ObjectId number,
ObjectClassifier varchar2
RETURN types.TmpHiearchyMapTableType
IS
TmpHierarchyMap types.TmpHiearchyMapTableType;
ThisTempId varchar2(32);
CURSOR spGetParents_cursor IS
SELECT
ReferencedId Id,
ParentId,
ChildId,
FROM TMP_HIERARCHYMAP
WHERE TmpUID = ThisTempId;
BEGIN
SELECT sys_guid() INTO ThisTempId FROM dual;
spRecursiveGetParents(ObjectId, ObjectClassifier, ThisTempId);
FOR oMap in spGetParents_cursor LOOP
TmpHierarchyMap.Extend(); **** BUT I haven't "Instantiate" the Nested Table yet ****
TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id
, oMap.ParentId
, oMap.ChildId
END LOOP;
DELETE FROM TMP_HIERARCHYMAP WHERE TmpUID = ThisTempId;
RETURN TmpHierarchyMap;
END spGetParentsTable;

It's annonyingly trivial to fix. In your declaration section try
    TmpHierarchyMap types.TmpHiearchyMapTableType :=  types.TmpHiearchyMapTableType();
    ...Cheers, APC
blog: http://radiofreetooting.blogspot.com

Similar Messages

  • How to return a OCI Table * (nested table) from OCI application to sqlplus

    Hi,
    How to return a OCI Table * (nested table) from OCI application to sqlplus prompt : OCITAble * shows up as empty on the SQLPLUS prompt.
    The ODCIAggregateTerminate member function's OUT parameter is OCITable * returnValue. After completion of this member function it displays data on the sqlplus prompt.
    My problem is that eventhough my OCITable(returnvalue) has elements appended or added to it. But when I return the OCITAble after completion
    of this member function the OCITable shows up as empty collection on the SQLPLUS prompt. But in the OCI code if I iterate through the collection
    I can print out the elements and see their values or data.
    Can any one let me know how I can make the elements or data in the collection available at SQLPLUS prompt after the completion of this member function.
    If my return value or OUT parameter of this member function is OCINumber * returnValue : then I can see the corresponding value assigned in the OCI Code
    and the same value is returned and visible on the SQLPLUS prompt. But when I use the OUT parameter as OCITAble * : then it shows up as empty collection.
    I don't really know why is it happening so.
    member function ODCIAggregateTerminate(
    self IN OUT MinDistanceImpl, returnValue OUT table_out1,
    flags IN number)
    return number
    as language C
    library custagg name "ODCIAggregateTerminate"
    with context
    parameters (
    context,
    self,
    self INDICATOR STRUCT,
    returnValue ,
    returnValue INDICATOR,
    flags,
    flags INDICATOR ,
    RETURN ),
    typedef OCITable table_out1;
    struct ntab_type
    OCINumber empno;
    OCINumber salary;
    OCIString * tst;
    OCIString * te;
    typedef struct ntab_type ntab_type;
    struct ntab_type_ind
    OCIInd _atomic;
    OCIInd empno;
    OCIInd salary;
    OCIInd tst;
    OCIInd te;
    typedef struct ntab_type_ind ntab_type_ind;
    extern "C" OCINumber * ODCIAggregateTerminate(
    OCIExtProcContext *context,
    MinDistanceImpl * self,
    MinDistanceImpl_ind * self_ind,
    table_out1 * returnValue,
    short * returnValue_ind,
    OCINumber * flags,
    short flags_ind)
    ocitypename for collection..
    ocitypename for element
    ociobjectnew for collection
    ociobjectNew's for elements
    ocicollappend of elements to collection
    then iterate thru collection
    and at them collection as those elements and we return that collection
    But is empty : on SQLPLUS prompt :
    Select Mindis(TT) from table1;
    TT(empno, salary, tstart, te)
    Table_Out1()

    > Can anyone pls let me know if there is some way to return an entire table from a function which
    is called from a stored procedure?
    For what purpose?
    Do you realise that this means pulling Megabytes (or even many Gugabytes) of data from disk, into the buffer cache, and then copying that data into PL/SQL memory (using a function) in order to give a stored proc that data?
    This is just plain crazy.. resource wise, performance wise, scalability wise.. this is exactly how NOT to use Oracle.
    Why don't you instead tell us what problem you want to solve. Forget for the moment what you think the solution should be. (and asking us how to get a potentially flawed solution, to work)
    Let's get an accurate problem definition so that we can provide you with suggestions and recommendation on what Oracle features can be used to address that problem.

  • How to assign Values to nested table and pass as parameter to procedure?

    How to assign Values to nested table and pass as parameter to procedure?
    Below is the Object and its type
    create or replace type test_object1 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type1 is table of test_object1;
    create or replace type test_object2 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type2 is table of test_object2;
    GRANT ALL ON test_object1 TO PUBLIC;
    GRANT ALL ON test_type1 TO PUBLIC;
    GRANT ALL ON test_object2 TO PUBLIC;
    GRANT ALL ON test_type2 TO PUBLIC;
    here is the table made of object type:
    create table test_object_tpe
    sl_num NUMBER,
    description VARCHAR2(100),
    main_val1 test_type1,
    main_val2 test_type2
    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS tot2;
    here is the procedure which inserts values into nested table:
    PROCEDURE INSERT_TEST_DATA(sl_num IN NUMBER,
    description IN VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    IS
    BEGIN
    FOR rec in p_main_val1.first..p_main_val1.last
    LOOP
    INSERT INTO xxdl.test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    sl_num
    ,description
    ,test_type1 (test_object1(
    p_main_val1(rec).val1,
                                       p_main_val1(rec).val2,
    p_main_val1(rec).val3
    ,test_type2 (test_object2( p_main_val2(rec).val1,
                        p_main_val2(rec).val2,
                        p_main_val2(rec).val3
    END LOOP;
    commit;
    END INSERT_TEST_DATA;
    here is the anonymoys block which assigns values to the object type and pass values into the procedure:
    set serveroutput on;
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1(1).val1 := 'testx1';
    inval1(1).val2 := 'testx2';
    inval1(1).val3 := 'testx3';
    inval2(1).val1 := 'testy1';
    inval2(1).val2 := 'testy2';
    inval2(1).val3 := 'testy3';
    CSI_PKG.INSERT_TEST_DATA(sl_num => p_sl_num,
    description => p_description,
    p_main_val1 => inval1,
    p_main_val2 => inval2
    end;
    Can anybody correct me.
    Thanks,
    Lavan

    Thanks for posting the DDL and sample code but whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    How to assign Values to nested table and pass as parameter to procedure?
    >
    Well you are doing almost everything wrong that could be done wrong.
    Here is code that works to insert data into your table (the procedure isn't even needed).
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    INSERT INTO test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /See Example 5-15 Referencing a Nested Table Element in Chap 5 Using PL/SQL Collections and Records in the PL/SQL doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/collections.htm#CJABEBEA
    1. You don't even need the procedure since all it does is a simple INSERT into the table which you can do directly (see my code above)
    inval1(1).val1 := 'testx1';There is no element one (1) of 'inval1' since you haven't created any elements yet. You need to EXTEND the collection to add an element
    inval1.extend();And then there is an empty element but 'inval1' is a container for objects of type 'test_object1' not for scalars like 'val1', 'val2', and 'val3'.
    So you can't do
    inval1(1).val1 := 'testx1';You have to create an instance of 'test_object1'
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');And so on for the other collection
    You don't need the procedure (as my sample code shows) but once you populate the variables properly it will work.

  • How do you set up nested rules for iTunes smart playlist

    How do you set up nested rules for a iTune smart playlist

    Hello \"alice\",
    It sounds like you want to add additional criteria to your Smart Playlists.  I found an article with steps you can use to refine your Smart Playlist.  Step 2 specifically has what I think you are looking for:
    2. To have iTunes add songs that match specific criteria, make sure to select "Match the following rule," then make your selections from the pop-up menus.
    For example, you might want iTunes to only add songs that are by a particular artist, or songs with at least a four-star rating.
    To add additional matching criteria, click the Add button.
    You can find the full article here:
    iTunes: How to create a Smart Playlist
    http://support.apple.com/kb/ht1801
    The article says it is archived.  In the current version of iTunes, in step 1 you will select File>New>Smart Playlist.  Also, if you need to edit an existing Smart Playlist, you can right click (or hold command while you click) on it and select Edit Smart Playlist. 
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.

    Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.
    when you copy n paste into a new table, all the cell sizes are changed.
    is there a way to put in a new table from your templates into an existing file, different to the standard very basic ones in insert table.
    I look forward to your answers.  Your help is very much appreciated.
    Also how do you search for question answers already written in this support area please.

    Hi Jason,
    In Numbers 3, you can select a whole table by clicking once in the table to make it active, then click once on the "bull's eye" at the top left.
    Now copy and paste. All formatting (and any cell content) is pasted intact. In Numbers 2.3 (Numbers '09) it is a little different for selecting a whole table. But I won't go into that unless you are using Numbers '09. Please reply.
    I don't like the look of the tables in Insert Table. I keep custom tables in My Templates. I have set Numbers > Preferences > General > For New Documents > Use template: (name of my favourite custom template)
    That opens when I launch Numbers, or ask for a new document (command n). Note that if you follow this preference setting, then Menu > File > New From Template Chooser (for another template) requires you to hold down the option key in that menu.
    Regards,
    Ian.
    Message was edited by: Yellowbox. All formatting (and any cell content) is pasted intact.

  • How do you get your money back from a charge you never even made on the app store?

    How do you get your money back from a charge you never even made on the app store?

    Contact iTunes.
    How to report an issue with Your iTunes Store purchase

  • How do you remove a web site from popular list?

    How do you remove a web site from popular list?

    luckyfromhialeah wrote:
    How do you remove a web site from popular list?
    If you mean from the Safari menubar item "Popular"
    Choose "Show All Bookmarks" from the Bookmark menu in the main menubar, or click the icon for that in Safari's menubar -
    The page that opens should show a list of Bookmarks. In the Left column, click the item under Collections named Bookmarks Bar.
    In the new view, locate the folder named Popular and click the reveal triagle to the left of its name - it will open and reveal all the items listed in Popular.
    Find the one you want to remove, click it once to select it, then press the Delete key on the keyboard.

  • How do you remove a web address from compatibility view option using a script?

    How do you remove a web address from compatibility view option in IE using a script or a GPO? 
    Not seeing any options.
    Casey
    This topic first appeared in the Spiceworks Community

    luckyfromhialeah wrote:
    How do you remove a web site from popular list?
    If you mean from the Safari menubar item "Popular"
    Choose "Show All Bookmarks" from the Bookmark menu in the main menubar, or click the icon for that in Safari's menubar -
    The page that opens should show a list of Bookmarks. In the Left column, click the item under Collections named Bookmarks Bar.
    In the new view, locate the folder named Popular and click the reveal triagle to the left of its name - it will open and reveal all the items listed in Popular.
    Find the one you want to remove, click it once to select it, then press the Delete key on the keyboard.

  • How do you delete an email address from your iPhone that's not in your contacts?

    How do you delete an email address from your iPhone that's not in your contacts?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • How do you access updates to apps from the App store after changing to a new ID because the password on the old ID was changed and you don't know what it is now?

    How do you access updates to apps from the App store after changing to a new ID because the password on the old ID was changed by the former husband and you don't know what it is now?  And you set up your own new ID and account but can NOT access the updates, from the App store for the many apps that you already have, because they require that you sign in with that former now inaccessible ID and account and password?  Call it a problem of modern times and changing relationships, if you want to be charitable.

    So I guess it will only be new apps that I download that are allowed to give me their updates while 13 updates wait for me on an ID I can no longer access.
    Yes...  sorry.
    In the future, if need be, you can re download your purchases for free  >  Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Good rule of thumb is to back up your purchases regardless  >  Mac App Store: Backing up your app purchases

  • How do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full

    how do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full.. HELP!

    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.

  • How do you move a quicktime movie from one iphoto library to another?

    How do you move a quicktime movie from one iphoto library to another?

    1 - export it from Library A via the File ➙ Export ➙ File Export menu with Kind = Original.
    2 - import it into Library B as you normally would.
    OT

  • How do you remove a credit card from your account?

    how do you remove a credit card from your account?

    Hello sammi094,
    The following article provides step-by-step instructions for changing your billing information.
    iTunes Store: Changing your payment information
    http://support.apple.com/kb/HT1918
    See what to do if None isn't showing or you can't select it.
    Cheers,
    Allen

  • How do you remove credit card information from your Apple ID

    How do you remove credit card information from your Apple ID.?  My dad was using my iTunes for awhile and he put his credit card on it and now, everything I want to buy something on the App Store or on iTunes, it asks for my dad's credit card information.  I want that taken off.  I just got some iTunes cards that I want to use but it won't let me

    Do you mean the App store? Both iTunes and the App store use what ever is set up on your appleID, be it credit card or iTunes card. Its the same account.

  • HT3702 How can you remove a credit card from your account?

    How can you remove a credit card from itunes account?

    See if this support document answers your question. Why can’t I select None when I edit my Apple ID payment information? - Apple Support

Maybe you are looking for

  • Import tablespace failed due to different release version for 10g

    I try to exp tablespaces from 10.2.0.2 (Enterprise Edition, UNIX) to our test server 10.2.0.1 (express eidtion, linux) with transportable tablespace, when import the tablespaces, get the following error: Export file created by EXPORT:V10.02.01 via co

  • How get java Object from webservice

    Hai i gave ArrayList<bean> , i can't get this ArrayList<bean> from webservice. How can i get ? via for each or iterator or any ????? Note: i iterated  but only one element was come from bean property  using next() of iterator . I need all property. a

  • How to delete a custom field created in Address Book template?

    It is possible to create a new custom field name in any of the pop-up field categories in the preferences template for Address Book. But, once created, there does not seem to be a way to delete or edit the newly created custom field name. That doesn'

  • How do I get Pages to recognize the Norwegian language in spell-check?

    I'm Ameican and I got my beautiful MacBook air with me in Norway.  I use Pages to write notes and do homework, but it doesn't have Norwegian as a language amunst the spellcheck dictionary.  It has Swedish and Danish ofcours, but it's not the same.  I

  • HELP!!! main page is in gibberish!!

    okay when i try to log onto http://192.168.1.1/ the language is in some kind of foreign language. i tried to translate it to everything but its in none of the languages. I bought this router yesterday and its been like that ever since Im running a Wi