Bind ordered pair of nested tables into cursor

Hello,
I'd like to ask you for help. I was searching for this topic, but haven't found any answer.
This is a very simple example that works with HR schema.
I have a stored type:
CREATE TYPE t_ids AS TABLE OF NUMBER(9);
and simple procedure. There is a cursor with paremeter that accepts nested table and uses MEMBER OF operator.
CREATE OR REPLACE PROCEDURE m_test
AS
CURSOR mycur (a_ids t_ids)
IS
SELECT last_name
FROM employees
WHERE employee_id MEMBER OF a_ids;
some_ids t_ids;
TYPE t_result IS TABLE OF employees.first_name%TYPE;
result_table t_result;
BEGIN
some_ids := t_ids(100,101,102);
OPEN mycur (some_ids);
FETCH mycur BULK COLLECT INTO result_table;
CLOSE mycur;
DBMS_OUTPUT.PUT_LINE('count: ' || result_table.COUNT);
END m_test;
This example works fine. BUT - What I need is to modify the cursor in this way:
CURSOR mycur (a_ids t_ids)
IS
SELECT last_name
FROM employees
WHERE *(employee_id,manager_id)* MEMBER OF (a_ids,a_ids);
Well - this does not function - and is't my question - which operator should I use to compare ordered pair with two nested tables?
Thank you!
Pavel Ruzicka
Edited by: user8117512 on 28.8.2009 6:12

user8117512 wrote:
No, no, pls. don't look at repeating a_ids. This is only an example. There could be two different nested tables.
There is, lets say,
(employee_id,manager_id) MEMBER OF (a_fist_table,a_second_table);But this syntax doesn't have a meaning (yet). So you'll have to explain what you mean with that syntax.
Possibilities:
- Treat the two independent collections a_first_table and a_second_table as a collection containing elements that are a tuple. Only use the ones with a subscript occuring in both collections. Then check if the tuple (employee_id,manager_id) occurs within that set.
- Check if employee_id or manager_id occurs within the set a_first_table UNION ALL a_second table. If so, then it's a member.
You'll have to be more specific, before we start guessing.
Regards,
Rob.

Similar Messages

  • How to bind the data from user table into user report

    Hi All,
      Please assist me to bind the data from user table into user report. I did create an user table with data and create a user report template (using Query Print Layout). How can I display my data into report format which I created before? Any sample program or document I can refer?
    Platform: SAPB1 2005A
    Add On Language: VB.Net 2003
    Thanks.
    rgds
    ERIC

    Hi Ibai,
      Thanks for your feed back. I give you an example.
    Let say now i wanna print employee list, so i will go
    1. Main Menu -> Reports -> HR -> Employee List
    2. Choose the Selection Criteria -> OK
    3. Matrix will display (Employee List)
    4. I can print the report click on print button
    5. Printing report
    My target
    1. Main Menu -> Eric_SubMenu -> Employee List
    2. Matrix will display (Employee List)
    3. Print button
    4. Print report
    My problem
    Now I would like to use my own report format. My own report format means I wanna add on my logo or do some customization within the employee report. So how I am going to do? I only able to display the employee list in matrix. How do I create a new report format and display it.
    Thanks.
    rgds
    ERIC

  • How to cast RECORD of nested tables into OBJECT of nested tables

    Right, we have an existing massive pl/sql package where some of the processing is taking too long so they want to try multithreading it.
    The data in this package is stored in an array of records which contains nested tables, which themselves contain nested tables.
    So, we want to split this table into 10, and submit them to 10 dbms_jobs to run concurrently, write the modified arrays to the database so they can be picked up again by the original process.
    I'm stuck on converting the associative array of data (containing tables of records) into objects which can be stored in the DB.
    My database objects:
    CREATE OR REPLACE
    TYPE ktest_claims_rt IS OBJECT
         col1 varchar2(10)
        ,col2 varchar2(10));
    CREATE OR REPLACE
      TYPE ktest_claims_tt IS TABLE OF ktest_claims_rt;
    CREATE OR REPLACE
    TYPE ktest_driver_rt IS OBJECT
         col1      varchar2(10)
        ,col2      varchar2(10)
        ,claims_nt ktest_claims_tt);
    CREATE OR REPLACE
      TYPE ktest_driver_tt IS TABLE OF ktest_driver_rt;
    CREATE OR REPLACE
    TYPE ktest_policy_rt IS OBJECT
         col1       varchar2(10)
        ,col2       varchar2(10)
        ,driver_nt  ktest_driver_tt);
    CREATE OR REPLACE
      TYPE ktest_policy_tt IS TABLE OF ktest_policy_rt;
    CREATE TABLE ktest_job_table
      (job_no        NUMBER
      ,tab_type      VARCHAR2(3)
      ,policy_nt     ktest_policy_tt
      NESTED TABLE policy_nt STORE AS policy_nested_tab
        (NESTED TABLE driver_nt STORE AS driver_nested_tab
           (NESTED TABLE claims_nt STORE AS claims_nested_tab))
    / And my local package versions:
       TYPE claims_rt IS RECORD
         col1 varchar2(10)
        ,col2 varchar2(10));
       TYPE claims_tt IS TABLE OF claims_rt INDEX BY PLS_INTEGER;
       TYPE driver_rt IS RECORD
         col1       varchar2(10)
        ,col2       varchar2(10)
        ,claims_nt  claims_tt);
       TYPE driver_tt IS TABLE OF driver_rt INDEX BY VARCHAR2(20);
       TYPE policy_rt IS RECORD
            policy_no   policy.policy_no%TYPE
           ,driver_tab  driver_tt
           ,other_col   VARCHAR2(20));
       TYPE policy_tt IS TABLE OF policy_rt
            INDEX BY pls_integer;
       main_table  policy_tt;What I can't get through my pea sized brain is how to turn "main_table" into an array based on ktest_policy_tt.
    I got as far as:
       FUNCTION convert (p_table IN policy_tt) RETURN ktest_policy_tt
       IS
          db_vers  ktest_policy_tt := ktest_policy_tt();
          db_rec   ktest_policy_rt;
       BEGIN
          FOR i IN p_table.FIRST..p_table.LAST
          LOOP
             db_rec := ktest_policy_rt(p_table(i).policy_no
                                      ,p_table(i).other_col
                                      ,ktest_driver_tt(p_table(i).driver_tab(i).col1
                                                      ,p_table(i).driver_tab(i).col2
                                                      ,ktest_claims_tt(p_table(i).driver_tab(i).claims_nt(i).col1
                                                                      ,p_table(i).driver_tab(i).claims_nt(i).col1
             db_vers(i) := db_rec;
          END LOOP;
       END;but, apart from the fact that it only coverts the first row of each table, it doesn't compile:
    LINE/COL ERROR
    139/10   PL/SQL: Statement ignored
    143/52   PLS-00306: wrong number or types of arguments in call to
             'KTEST_CLAIMS_TT'
    143/52   PLS-00306: wrong number or types of arguments in call to
             'KTEST_CLAIMS_TT'I'd appreciate any help as this is getting urgent.
    Thanks!

    I would recommend writing your function in a more stepwise, explicit fashion rather than trying to write the conversion as basically one big constructor.
    Firstly, you will require nested loops in your pl/sql code for the different levels of nested tables. This is not a choice, you need to do this.
    Within each level of looping, explicitly create the object of the desired type before adding it to the table / record as need be.
    cheers,
    Anthony

  • OCI doc says Cursor and Nested table have the same bind type SQLT_RSET but they don't

    5 Binding and Defining in OCI
    PL/SQL REF CURSORs and Nested Tables in OCI
    says SQLT_RSET is passed for the dty parameter.
    If I use SQLT_RSET for the return value of a function that returns a table and pass a statement handle's address for the OCI parameter data pointer, I expected that the statement handle will be instantiated as a result of executing the function on which I can further perform fetch, similar to a cursor. But it throws exception PLS-00382: expression is of wrong type ORA-06550: line 2, column 3. Is the above documentation wrong?
    From the OCI header file I see that for varray and nested table it mentions to use SQLT_NCO. I could find no example in the OCI documentation on how to pass or receive as return value a nested value when using SQLT_NCO.
    Please help before I shoot myself.

    So the Nested table I quoted in the doc is not actually used to mean a table type below?
    create type t_resultsetdata as object (
    i int, d decimal, c varchar(10)
    create type t_nested_resultsetdata as table of t_resultsetdata;
    create function Blah return t_nested_resultsetdata  is . . .
    For this you are saying to use SQL_NTY and not SQL_NCO. Can you tell where this usage is documented, because ocidfn.h says
    #define SQLT_NTY  108                              
    /* named object type */
    #define SQLT_NCO  122 
    /* named collection type (varray or nested table) */
    Another question - Because of the original document I said I followed, I thought I could treat cursor and nested table similarly in the calling application, i.e. I could repeatedly do a fetch on the OCIStmt* which will be bound for nested table. Now from what you say I understand I can't really bind a OCIStmt* for nested table but have an object type. That means it will get all the data of that collection in one go, right? LIke I said, lack of examples is making this tough. I don't want to look into OCI source code, as that will be too much.

  • Inserting Data into nested table

    I am exploring the differences between OBJECT & RECORD.
    As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
    Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
    CREATE OR REPLACE type sam as OBJECT
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    ---Nested Table---
    create or replace type t_sam as table of sam;
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    Error Message:
    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:   
    *Action:

    Ariean wrote:
    So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
    Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
    Ariean wrote:
    And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
    Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
    It could get stupidly .. er, stupid O_0
    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    CREATE TYPE t_dumber AS table of o_myobj2;
    O_0
    Ok, my brain's starting to hurt - I hope you get the idea
    Ariean wrote:
    Secondly is my understanding correct about OBJECT & RECORD?
    I can't think of any benefit of describing it another way.

  • Inserting data with the help of nested table...!!!

    The following block is giving error
    ORA-06502: PL/SQL: numeric or value error
    the signature and signature_bkp have the same structure
    So, can anybody help me out to solve this issue :
    for copying records from one table to another table
    Thanking You advancely
    DECLARE
    CURSOR c1
    IS
    SELECT *
    FROM signature
    WHERE creation_time > TRUNC ( SYSDATE ) - 100
    AND ROWNUM < 102;
    TYPE sig_typ IS TABLE OF signature%ROWTYPE;
    sig_t sig_typ;
    BEGIN
    OPEN c1;
    FETCH c1
    BULK COLLECT INTO sig_t;
    CLOSE c1;
    FORALL i IN sig_t.FIRST .. sig_t.LAST
    INSERT INTO signature_bkp
    VALUES sig_t ( i );
    COMMIT;
    END;
    --DKar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Or whether a INSERT statement with SELECT clause will do that for youby using this technique, it took 47:08:45 to copy 7252 rows
    and by using a cursor for loop took 49:03:23 to copy 13567 rows
    So there was appox. 40% increase in performance by using pl/sql. I thought it could be even faster using the bulk-bind ing features and nested tables.
    OR i just want to know ....how to correct the block of code that was given in my 1st msg without changing its logic.
    Thanks
    --DKar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Nested tables of user defined types

    Hello all,
    I have philosophical question I am hoping someone can answer for me, "To TYPE, or not to TYPE; that is the question."
    I have created several layers of nested tables in the form:
    CREATE TYPE xyz AS OBJECT();
    CREATE TYPE table_xyz AS TABLE OF xyz;
    CREATE TYPE abc AS OBJECT(
    nested_table1 table_xyz;
    and so on until I end up creating a main table with all these sub tables nested into it.
    But from what I understand oracle stores all of the information in a column of type NESTED TABLE into a single table, rather than one table per row. This means that if I declare a primary key in the nested table it will be against all values in the outer column, not just limited to the values in an individual row of the outer table. Plus it will not let me create foreign keys with in a nested table.
    So why should I use the above construct instead of simply creating separate tables, and use primary and foreign keys to relate them and joins to query?
    I can see the use for types in small cases (addresses, person, etc..) but I do not see the advantage of nested tables. Could someone shed some light on the subject for me?
    Thanks,
    Thomas

    I'll state an opinion, for what it's worth. First, if you are going in the direction of types and nested tables or other collections, you are buying into Oracle's object-relational approach. This has pros and cons as far as design considerations, complexity, and performance that is too involved to get into here. If you just need master/detail table relationships, stick with traditional design techniques. Nested tables can make DML code complex and many tools can't deal with them so you end up having to unnest(flatten) the collections. I'd especially stay away from them if you require multiple nested tables or nested tables within nested tables.

  • How to use nested tables object in oracle form

    Hello forum
    How all r u ..
    i need ur help guys, pls help me out...
    i m using an object oriented approach to design my database by using nested tables and
    varrays. it is quite done successfully.
    but the problem is when i m trying to use that object of nested table into the datablock of the form it is not been added to item list of that block.
    so what is the proper way to use these type of objects to the form.
    all ideas are welcomed and vry much required.
    pls give example if possible so easy to understand or have any demo form related to above case then pls post me to my id i.e [email protected]
    thank u all and expecting some expert solutions

    Hello Francois Degrelle...
    How r u doing ... i have searched the forum abt the above mentioned topic then i found that u have some demo form which will help out to explain the functionality of the nested table in forms ..
    will u pls me that form to my i.e [email protected] pls mail all the detail u have regarding using nested tables to forms and reports
    lots of thanks to u n advance.

  • Nested table in an ALV

    Hello All,
    I have a table which has another table as a column in it. i.e I have a nested table. I want to display a nested table in an ALV using the FM "REUSE_ALV_GRID_DISPLAY". Please help me how to achieve this.
    thanks,
    Anju

    Hi ,
    Please elaborate your question .
    From my understanding
    You will have to get the data from your nested table into one plan table and pass that to ALV.
    You can think of Block ALV as well.
    Regards,
    Uma Dave

  • Nested Tables on two rows

    I have created a nested table in the Context section of my report, which has a control level.  When I drag-n-drop the table onto the form, it is just one large row.  If I try to break the columns into multiple rows, the table no longer functions properly.
    How can I make a nested table into more than one row and it still work?

    Hi,
    What I could understand from your query is.
    You have a context of table type and is nested, may be the number of columns are more enough that it doesnot fit in one row of the form, so you wanted to publish a single instance/record data in 2 different rows is it so ..?
    well if so, if I were you instead of using table I will use subform with flowed westerntext layout by which all the (say 10 )colums will display in 2 rows with 5 columns each.
    Then I would do data bb inding individually.
    This was adviced by Otto and works perfectly, I am using this approach in several forms.
    Let me know if my understanding was wrong or if you find any issues implementing this approach.
    Cheers,
    Sai

  • Nested Table in Replication

    Hello there,
    (i)
    Any body tell me... if there is problm while have nested tables in schema that would be replicated.
    (ii)
    is there any problem having object type in replication.
    Thanks in advance.
    Parwaz Kamal

    Hi ,
    Please elaborate your question .
    From my understanding
    You will have to get the data from your nested table into one plan table and pass that to ALV.
    You can think of Block ALV as well.
    Regards,
    Uma Dave

  • NESTED TABLE BIND VARIABLE IN A REF CURSOR

    Hi,
    this works:
    open c_ref for v_sql using cp_asset_type
    where cp_asset_type is a nested tables passed into the proc as an 'in' parameter, but since the number of passed tables varies I loaded the nemes into an a nested table and tried the following:
    -- ELSIF BIND_COUNT.COUNT = 8 THEN
    -- OPEN C_REF FOR V_SQL
    -- USING BIND_COUNT(1),BIND_COUNT(2),BIND_COUNT(3),BIND_COUNT(4),BIND_COUNT(5),BIND_COUNT(6),BIND_COUNT(7),BIND_COUNT(8);     
    -- END IF;     
    which produced :
    ORA-22905 CANNOT ACCESS ROWS FROM A NON-NESTED TABLE ITEM
    my guess is that I'm passing the varchar2 names of the nested tables and the 'using' statement needs the actual table ????
    if this is true is there any way to pass a pointer for the bind variable nested tables?
    Thanks,
    Victor

    <br>i removed the AND...but m still getting the same error.
    <br>Is this a versioning problem...since urs is 9i and m using
    <br>Oracle8i Enterprise Edition Release 8.1.7.4.0
    <br> PROCEDURE sp_SearchByDriverName(i_C in varchar2,
    i_F in varchar2,
    i_LN in varchar2,
    i_FN in varchar2,
    o_Result out ABC_CURTYPE) is
    <br> tm_corp varchar2(2);
    <br> tm_fleet varchar2(6);
    <br> dc ABC_curtype;
    <br> begin
    <br> tm_c := getformattedc(i_C);
    <br> tm_f := getformattedf(i_f);
    <br> if i_FN is not null then
    <br> open dc for
    <br> SELECT distinct b.bus_ref_access_value,
    <br> i.individual_id,
    <br> br.mf_driver_last_name LN,
    <br> br.mf_driver_first_name FN,
    <br> substr(b.bus_ref_access_value, 4, 6) FLEET1,
    <br> (select '4444' from dual) --error is still coming here
    <br> FROM bus_ref_access_values b,
    <br> bus_ref_list brl,
    <br> individual i,
    <br> unit_contact_list f,
    <br> unit u,
    <br> bus_ref_current_prop br
    <br> WHERE b.bus_ref_id = br.bus_ref_id AND
    <br> b.bus_ref_id = brl.bus_ref_id AND
    <br> brl.reference_id = u.reference_id AND
    <br> u.unit_id = f.unit_id(+) AND
    <br> i.individual_id = f.individual_id AND
    <br> f.contact_type_ref = 'DR' AND
    <br> br.mf_driver_last_name like i_LN || '%' AND
    <br> br.mf_driver_first_name like i_FN || '%' AND
    <br> substr(b.bus_ref_access_value, 1, 2) = tm_c AND
    <br> substr(b.bus_ref_access_value, 4, 6) = tm_f AND
    <br> b.bus_ref_access_label = 'UNIT NUMBER'
    <br> ORDER BY 4, 3, 2;
    <br> close dc;
    <br>end if;

  • Elements order in Nested Tables

    In PL/SQL when I am adding element to a nested table of objects one by one(in order), and then trying to insert that nested table type to a physical table , the order of element changes. how can I prevent this behavior?

    Your example is incomplete and has errors. Oracle does not guarantee the order of anything unless you use an order by clause. So, if you expect the following to produce rows in some order:
    Open cur1 for select * from another_table;
    then you need to add an order by clause, such as:
    Open cur1 for select * from another_table order by id;
    The following does minimal correction, completion, and provides sample data to demonstrate:
    SCOTT@orcl_11gR2> create or replace TYPE coord AS OBJECT
      2    (id  number,
      3       x   number,
      4       y   number);
      5  /
    Type created.
    SCOTT@orcl_11gR2> create or replace TYPE coord_tab AS TABLE OF coord;
      2  /
    Type created.
    SCOTT@orcl_11gR2> create table demo_table
      2    (id     number,
      3       coords     coord_tab)
      4  NESTED TABLE coords STORE AS coords_tabb
      5  /
    Table created.
    SCOTT@orcl_11gR2> create table another_table
      2    (id  number,
      3       x   number,
      4       y   number)
      5  /
    Table created.
    SCOTT@orcl_11gR2> insert into another_table values (10, 20, 30)
      2  /
    1 row created.
    SCOTT@orcl_11gR2> insert into another_table values (60, 50, 40)
      2  /
    1 row created.
    SCOTT@orcl_11gR2> DECLARE
      2    type cur is ref cursor;
      3    cur1 cur;
      4    type rec_type is record
      5        (id  number,
      6         x   number,
      7         y   number);
      8    record_type rec_type;
      9    coords_tab coord_tab := coord_tab();
    10    idx number := 1;
    11  BEGIN
    12    Open cur1 for select * from another_table order by id desc;
    13    LOOP
    14        fetch cur1 into record_type;
    15        exit when cur1%notfound;
    16        coords_tab.extend() ;
    17        coords_tab(idx) := coord(record_type.id, record_type.x , record_type.y);
    18        idx := idx + 1;
    19    End LOOP;
    20  --  EXECUTE IMMEDIATE 'insert into demo_table values (1,:1)' USING coords_tab ;
    21    insert into demo_table values (1,coords_tab);
    22  End;
    23  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> select * from demo_table
      2  /
            ID
    COORDS(ID, X, Y)
             1
    COORD_TAB(COORD(60, 50, 40), COORD(10, 20, 30))
    1 row selected.
    SCOTT@orcl_11gR2>

  • Open a cursor containing a nested table?

    I have created a table with several nested tables by following the examples in: http://otn.oracle.com/docs/products/oracle8/doc_index.htm
    I am now trying to query one of these nested tables using the techniques that are described.
    The two techniques are (page 31 of above reference):
    (1) "Flattened" query.
    (2) Nested cursor
    Both of these techniques work by simple SQL queries in SQl*Plus.
    However, I get compilation errors when using identical queries when trying to open and return a cursor in a stored procedure.
    Can you please help? Is this supported in 8.1.7?
    Is there a better way to query and return data using OO4O to a windows client program?
    If necessary, I would be glad to provide code samples.
    Thank you,
    Casey Cummings

    Here is a copy of my test code for the question that I posted. Any help on how I can get nested table data back to a windows client would be greatly apreciated.
    Thank you.
    Casey Cummings
    --DDL.
    --Original table.
    CREATE TABLE MY_TABLE(
    MY_KEY INTEGER,
    MY_DATA VARCHAR2(2000));
    --Basic Object types.
    CREATE TYPE MY_NUMERIC_OBJTYP AS OBJECT(
    SEQUENCE INTEGER,
    DATUM NUMBER);
    CREATE TYPE MY_TEXT_OBJTYP AS OBJECT(
    SEQUENCE INTEGER,
    DATUM VARCHAR2(255));
    --Table type. Table of basic objects.
    CREATE TYPE MY_NUMERIC_TABTYP AS TABLE OF MY_NUMERIC_OBJTYP;
    CREATE TYPE MY_TEXT_TABTYP AS TABLE OF MY_TEXT_OBJTYP;
    --Add nested tables to original table.
    ALTER TABLE MY_TABLE ADD(
    MY_NUMERIC_NTAB MY_NUMERIC_TABTYP)
    NESTED TABLE MY_NUMERIC_NTAB STORE AS MY_NUMERIC_TABLE;
    ALTER TABLE MY_TABLE ADD(
    MY_TEXT_NTAB MY_TEXT_TABTYP)
    NESTED TABLE MY_TEXT_NTAB STORE AS MY_TEXT_TABLE;
    --Insert test data in the main, unnested table.
    INSERT INTO MY_TABLE(
    MY_KEY, MY_DATA
    )VALUES(
    1001, 'RECORD-1001');
    COMMIT;
    --Create the actual nested tables.
    UPDATE MY_TABLE SET
    MY_NUMERIC_NTAB = MY_NUMERIC_TABTYP();
    UPDATE MY_TABLE SET
    MY_TEXT_NTAB = MY_TEXT_TABTYP();
    COMMIT;
    --Insert test data into the nested tables.
    INSERT INTO TABLE(
    SELECT X.MY_NUMERIC_NTAB
    FROM MY_TABLE X
    WHERE MY_KEY = 1001
    )VALUES(
    1,901);
    INSERT INTO TABLE(
    SELECT X.MY_NUMERIC_NTAB
    FROM MY_TABLE X
    WHERE MY_KEY = 1001
    )VALUES(
    2,902);
    INSERT INTO TABLE(
    SELECT X.MY_NUMERIC_NTAB
    FROM MY_TABLE X
    WHERE MY_KEY = 1001
    )VALUES(
    3,903);
    INSERT INTO TABLE(
    SELECT X.MY_TEXT_NTAB
    FROM MY_TABLE X
    WHERE MY_KEY = 1001
    )VALUES(
    1,'ONE');
    COMMIT;
    BOTH OF THESE QUERYS WORK WHEN ENTERED IN SQL*PLUS.
    --"FLATTENED" QUERY
    SELECT X.MY_DATA, N.SEQUENCE, N.DATUM, T.SEQUENCE, T.DATUM
    FROM
    MY_TABLE X,
    TABLE(X.MY_NUMERIC_NTAB) N,
    TABLE(X.MY_TEXT_NTAB) T
    WHERE X.MY_KEY = 1001;
    --"CURSOR" QUERY
    SELECT X.MY_DATA,
    CURSOR(
    SELECT *
    FROM TABLE (MY_NUMERIC_NTAB) ),
    CURSOR(
    SELECT *
    FROM TABLE (MY_TEXT_NTAB) )
    FROM MY_TABLE X
    WHERE X.MY_KEY = 1001;
    CREATE OR REPLACE PACKAGE MANAGE_TEST AS
    TYPE THE_CURSOR IS REF CURSOR;
    PROCEDURE QUERY_TEST(
    MY_CURSOR IN OUT THE_CURSOR
    END;
    CREATE OR REPLACE PACKAGE BODY MANAGE_TEST AS
    PROCEDURE QUERY_TEST(
    MY_CURSOR IN OUT THE_CURSOR
    AS
    BEGIN
    OPEN MY_CURSOR FOR
    --"FLATTENED" QUERY
    SELECT X.MY_DATA, N.SEQUENCE, N.DATUM, T.SEQUENCE, T.DATUM
    FROM
    MY_TABLE X,
    TABLE(X.MY_NUMERIC_NTAB) N,
    TABLE(X.MY_TEXT_NTAB) T
    WHERE X.MY_KEY = 1001;
    END;
    END;
    *****************Errors:
    LINE/COL ERROR
    8/5 PL/SQL: SQL Statement ignored
    11/13 PLS-00201: identifier 'X.MY_NUMERIC_NTAB' must be declared
    CREATE OR REPLACE PACKAGE BODY MANAGE_TEST AS
    PROCEDURE QUERY_TEST(
    MY_CURSOR IN OUT THE_CURSOR
    AS
    BEGIN
    OPEN MY_CURSOR FOR
    --"CURSOR" QUERY
    SELECT X.MY_DATA,
    CURSOR(
    SELECT *
    FROM TABLE (MY_NUMERIC_NTAB) ),
    CURSOR(
    SELECT *
    FROM TABLE (MY_TEXT_NTAB) )
    FROM MY_TABLE X
    WHERE X.MY_KEY = 1001;
    END;
    END;
    *****************Errors:
    LINE/COL ERROR
    11/11 PLS-00103: Encountered the symbol "SELECT" when expecting one of
    the following:
    ( ) - + mod not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable>
    table avg count current exists max min prior sql stddev sum
    variance execute multiset the both leading trailing forall
    year month DAY_ HOUR_ MINUTE_ second TIMEZONE_HOUR_
    TIMEZONE_MINUTE_ time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL stri
    12/41 PLS-00103: Encountered the symbol "," when expecting one of the
    following:
    ; return returning and or
    null

  • Error in bulk collect into nested table

    I keep getting an error while trying to compile this line:
    fetch c_juros bulk collect into wrk_juros_plano(p_ind_segreg);
    LINE/COL ERROR
    0/0      PLS-00801: internal error [74306]When i put that single line into comments it goes fine. Sure it doesn't do what I want.
    The data structure i use is as follows:
      cursor c_juros(p_ind_segreg in varchar2) is
        select (((power(1 + (i.prc_juros_atuari_ano / 100), 1 / 12) - 1) * 100) / 100) prc_juros_efetiv_mes,
               i.dat_inic_vigenc,
               (nvl(i.dat_fim_vigenc, sysdate) + 1) dat_fim_vigenc,
               i.ind_segreg
          from v_indexador_taxa_atuarial i
         where i.ind_segreg = p_ind_segreg
         order by i.dat_inic_vigenc;
      type t_juros_plano     is table of c_juros%rowtype;
      type t_tab_juros_plano is table of t_juros_plano index by binary_integer;
      wrk_juros_plano t_tab_juros_plano;the code goes like this:
      begin
        if not(wrk_juros_plano.exists(p_ind_segreg))
        then
          if c_juros%isopen
          then
            close c_juros;
          end if;
          open c_juros(p_ind_segreg);
          wrk_juros_plano(p_ind_segreg) := t_juros_plano();
          fetch c_juros bulk collect into wrk_juros_plano(p_ind_segreg);
        end if;
      ...p_ind_segreg is my input parameter, that should be the index of the array.
    The purpose is to create the parameter indexed element if it doesn't already exist, fetching it
    from the cursor, that defines a nested table.
    I tried removing the initialization line to no effect, among other things.

    Ok, I just found out a way around it. It works, but that error is probably a bug, cause workarounds are not really cute.
    I declared a nested table compatible with the element from the associative array:
    wrk_juros t_juros_plano;and chaged that line that was causing the error
    fetch c_juros bulk collect into wrk_juros_plano(p_ind_segreg);for
    fetch c_juros bulk collect into wrk_juros;
    wrk_juros_plano(p_ind_segreg) := wrk_juros;Awesome =\

Maybe you are looking for