MetaData for nested table type

in a nested table a column is of datatype "TYPE"
so how can i get metadata for this column..
if "OPTIONS" is a column of datatype "TYPE"
and it has 2 columns option_id and option_value
then when i'am trying to get
array.getBaseTypeName
m gettin TAB_TY_OPTION_DETAILS
like this only..
how can i get metadata for this datatype.
Thanks in advance.

check out ResultSetMetaData

Similar Messages

  • Trigger how to get new and old value for nested table column?

    Hi,
    I have created a nested table based on the following details:
    CREATE TYPE typ_item AS OBJECT --create object
    (prodid NUMBER(5),
    price NUMBER(7,2) )
    CREATE TYPE typ_item_nst -- define nested table type
    AS TABLE OF typ_item
    CREATE TABLE pOrder ( -- create database table
    ordid NUMBER(5),
    supplier NUMBER(5),
    requester NUMBER(4),
    ordered DATE,
    items typ_item_nst)
    NESTED TABLE items STORE AS item_stor_tab
    INSERT INTO pOrder
    VALUES (800, 80, 8000, sysdate,
    typ_item_nst (typ_item (88, 888)));
    Now I would like to create a trigger on table pOrder for after insert or update or delete
    and I would like to track the new and old value for the columns inside nested table.
    Can anybody direct me how to do it?
    I would like to know the sytax for it like:
    declare
    x number;
    begin
    x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
    end;
    Hope my question is clear.
    Thanks,
    Lavan

    Hi,
    Try like this:
    CREATE OR REPLACE TRIGGER PORDER_I
    BEFORE INSERT
    ON PORDER
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    DECLARE
      items_new typ_item_nst;
      ordid_NEW NUMBER;
    BEGIN
    FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price:  ' || :new.items(I).price );
    END LOOP;
    END;Regards,
    Peter

  • Java call stored procedure with nested table type parameter?

    Hi experts!
    I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
    The following is my pl/sql code:
    create or replace package test_package as
    type row_abc is record(
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    type matrix_abc is table of row_abc index by binary_integer;
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    END test_package;
    create or replace package body test_package as
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    IS
    v_sn NUMBER(8):=0 ;
    BEGIN
    LOOP
    EXIT WHEN v_sn>5 ;
    v_sn := v_sn + 1;
    p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
    p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
    p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
    END LOOP ;
    END ;
    END test_package ;
    My java code is following, it doesn't work:
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection
    ("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
    con.setAutoCommit(false);
    CallableStatement ps = null;
    String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
    ps = con.prepareCall(sql);
    ps.setString(1,"p1");
    ps.setString(2,"p2");
    ps.setString(3,"p3");
    ps.registerOutParameter(4,OracleTypes.CURSOR);
    ps.execute();
    ResultSet rset = (ResultSet) ps.getObject(1);
    error message :
    PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Regards
    Louis

    Louis,
    If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
    create or replace type ROW_ABC as object (
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    create or replace type MATRIX_ABC as table of ROW_ABC
    /Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
    For your information, there are also code samples of how to do this on the OTN Web site.
    Good Luck,
    Avi.

  • How to use nested table types with XDK

    Im using Oracles XDK (xml development kit) to create xml-documents from data in database.4
    Problem: I need to use nested tables but when trying to create nested table types I get error: A Table type may not contain a nested table type or VARRAY.
    Hope I make myself clear! Are there any solutions or workarounds to this problem?
    Help appreciated, thanks!

    Jesper,
    I asked similar question last year (search for Tapsell, you will see my posting). Under 8.1.7 the "nesting" seems restricted to one level down. Thus you cannot create a type using another object that itself includes a nested table. Under Oracle 9, against which most current examples seem based, this limitation is removed making things easier. Under 8.1.7 the workaround I have used is to use the CAST syntax. This is not as neat, but it works.

  • HOw to improve insert/update/select  for nested table.

    Hi All,
    I think this is my second thread for nested table.
    i just want to know what are the different ways available to improve the insert/update/select operation on Nested table.
    Thanks in advance.

    By not using a nested table for data storage in the first place...
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:8135488196597
    Perhaps Parallel Query/DML might give some relief.

  • Error while create trigger on for nested table

    I want to insert a record into a nested table.For this, I created a view for the table, which includes the nested table.It told me ORA-25015 cannot perform DML on this nested table view column.So I created a trigger for the nested table.However, it told me that ORA-25010 Invalid nested table column name in nested table clause.I think my nested table is valid, i don't konw why did it appear this kind of problem?
    My table is
    CREATE TABLE ENT
    ID NUMBER(7) NOT NULL,
    CREATE_DATE VARCHAR2(11 BYTE),
    UPDATE_DATE VARCHAR2(11 BYTE),
    DEPTS VARRAY_DEPT_SEQ
    CREATE OR REPLACE
    TYPE DEPT AS OBJECT
    ID NUMBER(8),
    ANCHOR VARCHAR2(20),
    CREATE OR REPLACE
    TYPE " VARRAY_DEPT_SEQ" as varray(930) of DEPT
    CREATE OR REPLACE VIEW ENT_NESTED_VIEW
    (ID, CREATE_DATE, UPDATE_DATE, DEPTS)
    AS
    select e.ID,cast(multiset(select r.id,r.anchor from ent z, table(z.depts) r where z.ID=e.ID )as varray_dept_seq)
    FROM ENT e
    Then when I created trigger;
    CREATE OR REPLACE TRIGGER EMP.ENT_NESTED_TRI
    INSTEAD OF INSERT
    ON NESTED TABLE DEPTS OF EMP.ENT_NESTED_VIEW
    REFERENCING NEW AS New OLD AS Old PARENT AS Parent
    FOR EACH ROW
    BEGIN
    END ;
    I met the problem: ORA-25010 Invalid nested table column name in nested table clause
    Could you please tell me the reason
    Thank you!
    My insert SQL is:
    insert into table(select depts from ent_nested_view where id=1856) values(varray_dept_seq(dept(255687,'AF58743')))
    Message was edited by:
    user589751

    Hi,TongucY
    Compared with the "Referencing Clause with Nested Tables" part of this reference -
    http://psoug.org/reference/instead_of_trigger.html, I found the answer of this
    quesion. That is "CREATE OR REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of
    DEPT". It turns to be a varying array, not a nested table. It should be "CREATE OR
    REPLACE TYPE " VARRAY_DEPT_SEQ" as table of DEPT". That is OK. Thank you very
    much!
    While there is an another question, if I create a varying array like" CREATE OR
    REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of DEPT " and I want to insert
    a record into the varying array, which the record has been existed.The method that
    create a view and a trigger seems not to be effective.
    For instance,
    There is a record in the table
    ID:1020
    CREATE_DATE:2005-10-20
    UPDATE_DATE:2007-2-11
    DETPS: ((10225,AMY))
    I want to ask this record to be
    ID:1020
    CREATE_DATE:2005-10-20
    UPDATE_DATE:2007-2-11
    DETPS: ((10225,AMY),(10558,TOM))
    How should I do?
    Could you please help me?
    Best regards.
    Message was edited by:
    user589751

  • Need help for record/table type

    Hi, All,
    I have a table below and I need to use a procedure/function to return a list of values out and use anther procedure (array with multiple values in) to update the database. Could someone please give some examples?
    Here are my questions:
    1.     I need to create a user_defined_type to hold the list of info (array like, with more fields). Does the table type with %rowtype do that? If not, Could you please give an example?
    2.     if I do
    SELECT * INTO V_test(1) FROM PREO_profile
    where user_id = '1';
    can the 3 records of user_id 1 all be selected in the V_test table? If not, could you please tell me what to do?
    Thanks a lot.
    PREO_profile:
    User_id     N_id          M_id
    1      11 111
    1      22 222
    1      33 333
    2      11 111
    2      22 222
    2      33 333
    CREATE OR REPLACE PROCEDURE test_updatePro
    (user_id in varchar2,
    profile_info out T_Test)AS
    Type T_Test is table of PREO_profile%rowtype
    index by binary_integer;
    V_test T_Test;
    BEGIN
         SELECT * INTO V_test(1) FROM PREO_profile
         where user_id = '1';
    END;

    Here is one approach. This works in 9iR2. It's worth noting this functionality is evolving quite fast. Consequently, stuff that works in 9.2 may well not work in 9.0.1 and can probably be done much neater in 10g.
    Let's start by creating some tables....
    SQL> CREATE TABLE preo (user_id NUMBER, m_id NUMBER, n_id NUMBER);
    Table created.
    SQL> INSERT INTO preo VALUES (1, 11, 111);
    1 row created.
    SQL> INSERT INTO preo VALUES (1, 22, 222);
    1 row created.
    SQL> INSERT INTO preo VALUES (1, 33, 333);
    1 row created.
    SQL> INSERT INTO preo VALUES (2, 11, 111);
    1 row created.
    SQL> INSERT INTO preo VALUES (2, 22, 222);
    1 row created.
    SQL> INSERT INTO preo VALUES (2, 33, 333);
    1 row created.
    SQL> CREATE TABLE neo_preo AS SELECT * FROM preo WHERE 1=0;
    Table created.
    SQL> We'll need some types we need for communicating between processes....
    SQL> CREATE OR REPLACE TYPE preo_t AS OBJECT (u_id NUMBER, n_id NUMBER, m_id NUMBER);
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE preo_nt IS TABLE OF preo_t;
      2  /
    Type created.
    SQL> Here are methods to populate an array (actually a nested table)....
    SQL> CREATE OR REPLACE FUNCTION get_preo (p_uid IN NUMBER) RETURN preo_nt
      2  AS
      3    return_value preo_nt := preo_nt();
      4  BEGIN
      5    SELECT preo_t(user_id, n_id, m_id)
      6    BULK COLLECT INTO return_value
      7    FROM   preo
      8    WHERE  user_id = p_uid;
      9    RETURN return_value;
    10  END;
    11  /
    Function created.
    SQL>... and consume that array....
    SQL> CREATE OR REPLACE PROCEDURE ins_neo_preo (p_newrows IN preo_nt)
      2  AS
      3  BEGIN
      4     INSERT INTO neo_preo
      5     SELECT * FROM TABLE(CAST(p_newrows AS preo_nt));
      6  END;
      7  /
    Procedure created.
    SQL> So now we're ready to rock!
    SQL> DECLARE
      2      nt  preo_nt;
      3  BEGIN
      4      nt := get_preo(1);
      5      ins_neo_preo(nt);
      6  END;
      7  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> SELECT * FROM neo_preo
      2  /
       USER_ID       M_ID       N_ID
             1        111         11
             1        222         22
             1        333         33
    SQL> A little bit of limbo, a little bit of samba!
    Cheers, APC

  • Building an object of nested table types

    Hi,
    Looking for suggestions for the following.
    I have a procedure with 4 table types.
    They are in a hierarchical order so that 4 is the child of 3, 3 is the child of 2 and 2 is the child of 1.
    One of the columns of table 1 is a table type holding all the child records from table 2,
    One of the columns of table 2 is a table type holding all the child records from table 3,
    One of the columns of table 3 is a table type holding all the child records from table 4,
    I have 4 cursors that pull out all of the data to populate each of my 4 table types.
    I am trying to figure out how to nest my fetches to populate all of my table types to create a single object that hold all of my data.
    It’s a table of a table of a table of a table.
    Column 3 of table 1 holds table 2
    Column 3 of table 2 holds table 3
    Column 3 of table 3 holds table 4
    I’ve tried creating my procedure like this (pseudo code)
    declare
    tab_1 tab_1_type;
    tab_2 tab_2_type;
    tab_3 tab_3_type;
    tab_4 tab_4_type;
    cursor get_tab_1 is
    select col1, col2, tab_2 – added the table type for the child records
    from data_table_1
    cursor get_tab_2(tab_1_pk in number) is
    select col1, col2, tab_3 – added the table type for the child records
    from data_table_2
    where tab_2_fk = tab_1_pk
    cursor get_tab_3(tab_2_pk in number) is
    select col1, col2, tab_4 – added the table type for the child records
    from data_table_3
    where tab_3_fk = tab_2_pk
    cursor get_tab_4(tab_3_pk in number) is
    select col1, col2, col3
    from data_table_4
    where tab_4_fk = tab_3_pk
    begin
    open get_tab_1;
    loop
    open get_tab_2
    loop
    open get_tab_3
    loop
    open get_tab_4(tab_3_pk);
    bulk collect get_tab_4 into tab_4;
    close get_tab_4;
    fetch get_tab_3 into tab_3;
    tab_4:= null;
    exit when get_tab_3 %notfound;
    end loop;
    close get_tab_3;
    fetch get_tab_2 into tab_2;
    tab_3:= null;
    exit when get_tab_2 %notfound;
    end loop;
    close get_tab_2;
    fetch get_tab_1 into tab_1;
    tab_3:= null;
    exit when get_tab_1 %notfound;
    end loop;
    close get_tab_1;
    l_return := tab_1;
    end;
    The above won’t work because once the cursor is opened the child tables will be assigned values of null before they have had a chance to populate from the nested fetches.
    It’s almost as if I need to execute the fetch and update the extra columns afterwards somehow, something like:
    fetch get_tab_3 into tab_3;
    tab_3.col3 := tab_4;
    tab_4 := null;
    end loop;
    close get_tab_3;
    can I do that?
    Also the above seems very cumbersome. If there is a more elegant way of building up this object I’d like to hear it.
    Cheers
    Yog

    Interesting little exercise getting a 3 deep nested structure using a single SQL. Below is my attempt. You should be able to run it in any schema that has CREATE TYPE privs.
    SQL> -- Nested structure design:
    SQL> --
    SQL> -- USER LIST = (
    SQL> -- (USER1,OBJECT_LIST1).., (USERn,OBJECT_LISTn)
    SQL> -- )
    SQL> --
    SQL> -- LIST OF OBJECTS = (
    SQL> -- (TYPE1, NAME_LIST1).., (TYPEn, NAME_LISTn)
    SQL> -- )
    SQL> --
    SQL> -- LIST OF NAMES = ( NAME1..,NAMEn )
    SQL>
    SQL>
    SQL> create or replace type TObjectList is table of varchar2(50)
    2 /
    Type created.
    SQL>
    SQL> create or replace type TObjType is object(
    2 obj_type varchar2(50),
    3 obj_list TObjectList
    4 );
    5 /
    Type created.
    SQL>
    SQL> create or replace type TObjTypeList is table of TObjType;
    2 /
    Type created.
    SQL>
    SQL> create or replace type TUser is object(
    2 user_name varchar2(50),
    3 objects TObjTypeList
    4 );
    5 /
    Type created.
    SQL>
    SQL> create or replace type TUserList is table of TUser;
    2 /
    Type created.
    SQL>
    SQL> col NESTED_STRUCTURE format a100
    SQL>
    SQL> -- constructing the above user list (have made the start of the USER bold in the output below)
    SQL> select
    2 CAST( COLLECT(
    3 TUser(
    4 username,
    5 CAST( MULTISET(
    6 select
    7 TObjType(
    8 object_type,
    9 CAST( COLLECT(o.object_name) as TObjectList)
    10 )
    11 from all_objects o
    12 where o.owner = u.username
    13 group by
    14 o.object_type
    15 ) as TObjTypeList
    16 )
    17 )
    18 ) as TUserList
    19 ) as NESTED_STRUCTURE
    20 from all_users u
    21 where u.username in ('BILLY','DBSNMP')
    22 /
    NESTED_STRUCTURE(USER_NAME, OBJECTS(OBJ_TYPE, OBJ_LIST))
    TUSERLIST(TUSER('BILLY', TOBJTYPELIST(TOBJTYPE('FUNCTION', TOBJECTLIST('GETEMP', 'GETEMP2', 'TESTRET
    URN', 'WTF', 'ANOOP_REF')), TOBJTYPE('INDEX', TOBJECTLIST('PK_DEPT', 'PK_EMP')), TOBJTYPE('PROCEDURE
    ', TOBJECTLIST('USESEQ1', 'FOOPROC', 'W')), TOBJTYPE('TABLE', TOBJECTLIST('X', 'LOAD_TABLE', 'DEPT',
    'EMP', 'BONUS', 'SALGRADE')), TOBJTYPE('TYPE', TOBJECTLIST('TEMP', 'TEMPLOYEE', 'TX', 'TARRAY2D', '
    TARRAY1D', 'TARRAY3D', 'TOBJECT', 'TOBJTYPE', 'TOBJECTLIST', 'TOBJTYPELIST', 'TUSER', 'TUSERLIST', '
    SYSTPTkQoC5hBR+DgQPsKOl0PFQ==', 'SYSTPTkQoC5hyR+DgQPsKOl0PFQ==', 'SYSTPTkQoC5qzR+DgQPsKOl0PFQ==', 'S
    YSTPTkQoC5raR+DgQPsKOl0PFQ==')))), TUSER('DBSNMP', TOBJTYPELIST(TOBJTYPE('INDEX', TOBJECTLIST('MGMT_
    DB_FILE_GTT_PK', 'MGMT_DB_SIZE_GTT_PK')), TOBJTYPE('PACKAGE', TOBJECTLIST('MGMT_RESPONSE')), TOBJTYP
    E('PACKAGE BODY', TOBJECTLIST('MGMT_RESPONSE')), TOBJTYPE('SEQUENCE', TOBJECTLIST('MGMT_RESPONSE_CAP
    TURE_ID', 'MGMT_RESPONSE_SNAPSHOT_ID')), TOBJTYPE('TABLE', TOBJECTLIST('MGMT_SNAPSHOT', 'MGMT_SNAPSH
    OT_SQL', 'MGMT_BASELINE', 'MGMT_BASELINE_SQL', 'MGMT_CAPTURE', 'MGMT_CAPTURE_SQL', 'MGMT_RESPONSE_CO
    NFIG', 'MGMT_LATEST', 'MGMT_LATEST_SQL', 'MGMT_HISTORY', 'MGMT_HISTORY_SQL', 'MGMT_TEMPT_SQL', 'MGMT
    DBFILE_GTT', 'MGMT_DB_SIZE_GTT')), TOBJTYPE('VIEW', TOBJECTLIST('MGMT_RESPONSE_BASELINE')))))
    SQL>
    PS. To understand how the SQL works, run it from the inside out - i.e. run the innermost select on its own to see the output and then add to it until the full select is reached.

  • Public Synonyms for Nested Tables - Insertion Problem

    Hi,
    we are facing a problem during implementation. Our DB set up
    is , we will be having two schema named OWNR and COPY.
    In the schema, OWNR we have to create all the tables,
    types,procedures, packages and obj.....This schema will have
    both DDL and DML privileges.
    In the schema, COPY we are not supposed to create any tables,
    objects. We have to create public synonyms for all the tables,
    types, procedures... in OWNR and grant ALL privilege to the
    schema COPY.The schema, COPY will have only DML privileges.
    The problem is we have some nested tables in our application.
    When I try to insert into the synonym which is created for the
    nested table, it is not allowing me to insert..The whole
    implementation is stucked..Please help.The scripts are given
    below.......
    We have a type name SITA_ADDRESS_TY which is used by the nested
    table SITA_ADDRESSES_NT.Script used for creating the Type,Nested
    table,Table, Public Synonym and granting all privilege to these
    types and tables are
    CREATE OR REPLACE TYPE SITA_ADDRESS_TY AS OBJECT (
    SITA_ADDRESS VARCHAR2(10),
    REMARKS VARCHAR2(100)) ;
    PROMPT SITA_ADDRESSS_NT...
    CREATE OR REPLACE TYPE SITA_ADDRESSES_NT AS TABLE OF
    SITA_ADDRESS_TY ;
    Using this nested table we have created the table,
    UMS_SITA_ADDRESS
    CREATE TABLE UMS_SITA_ADDRESS (
    COMPANY_CODE VARCHAR2 (6) NOT NULL,
    AIRLINE_CODE VARCHAR2 (6) NOT NULL,
    DESTINATION VARCHAR2 (6) NOT NULL,
    SITA_ADDRESS SITA_ADDRESSES_NT)
    TABLESPACE EKUMDAT
    PCTFREE 5
    PCTUSED 40
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    NEXT 64K
    PCTINCREASE 0
    MINEXTENTS 1
    MAXEXTENTS 505
    FREELISTS 1 FREELIST GROUPS 1 )
    NOCACHE
    NESTED TABLE SITA_ADDRESS STORE AS UMSNT_SITA_ADDRESS ;
    PROMPT SYNONYM SITA_ADDRESS_TY...
    CREATE PUBLIC SYNONYM SITA_ADDRESS_TY FOR SITA_ADDRESS_TY
    PROMPT SYNONYM SITA_ADDRESSES_NT...
    CREATE PUBLIC SYNONYM SITA_ADDRESSES_NT FOR SITA_ADDRESSES_NT
    PROMPT UMS_SITA_ADDRESS...
    CREATE PUBLIC SYNONYM UMS_SITA_ADDRESS FOR UMS_SITA_ADDRESS
    Granting Privileges
    PROMPT SITA_ADDRESS_TY...
    GRANT EXECUTE ON SITA_ADDRESS_TY TO COPY
    PROMPT SITA_ADDRESSS_NT...
    GRANT EXECUTE ON SITA_ADDRESSES_NT TO COPY
    PROMPT UMS_SITA_ADDRESS...
    GRANT ALL ON UMS_SITA_ADDRESS TO COPY
    When I connect to copy and desc UMS_SITA_ADDRESS, the structure
    is
    SQL> desc ums_sita_address
    Name Null? Type
    COMPANY_CODE NOT NULL VARCHAR2(6)
    AIRLINE_CODE NOT NULL VARCHAR2(6)
    DESTINATION NOT NULL VARCHAR2(6)
    SITA_ADDRESS
    OWNR.SITA_ADDRESSES_NT
    Why is it so??. Even though I have a synonym for
    SITA_ADDRESSES_NT, it is not referencing the synonym but instead
    refer the OWNR.SITA_ADDRESSES_NT
    Because of this when I try to insert into ums_sita_address(in
    schema COPY), it is giving the following error,
    SQL> insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_NT());
    insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_NT())
    ERROR at line 1:
    ORA-00932: inconsistent datatypes
    But when the same connect to OWNR and try to insert with the
    same stmt, it is inserting...
    Our middle tier can connect only to COPY schema alone..Is there
    anything to be done in the DBA side to achieve this??.
    Please help from your valuabe experience...Or can you ask your
    collegues if they have got a soln to this probs..Our
    implementation team is stucked with this...
    Thanks
    Priya

    Hi
    I am not sure but maybe you need to use this command:
    SQL> insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_TY());
    SITA_ADDRESSES_TY() instead SITA_ADDRESSES_NT
    Regards

  • Public Synonyms for Nested Tables - Insertion Problem  - Please Help!!!!!

    Hi,
    we are facing a problem during implementation. Our DB set up
    is , we will be having two schema named OWNR and COPY.
    In the schema, OWNR we have to create all the tables,
    types,procedures, packages and obj.....This schema will have
    both DDL and DML privileges.
    In the schema, COPY we are not supposed to create any tables,
    objects. We have to create public synonyms for all the tables,
    types, procedures... in OWNR and grant ALL privilege to the
    schema COPY.The schema, COPY will have only DML privileges.
    The problem is we have some nested tables in our application.
    When I try to insert into the synonym which is created for the
    nested table, it is not allowing me to insert..The whole
    implementation is stucked..Please help.The scripts are given
    below.......
    We have a type name SITA_ADDRESS_TY which is used by the nested
    table SITA_ADDRESSES_NT.Script used for creating the Type,Nested
    table,Table, Public Synonym and granting all privilege to these
    types and tables are
    CREATE OR REPLACE TYPE SITA_ADDRESS_TY AS OBJECT (
    SITA_ADDRESS VARCHAR2(10),
    REMARKS VARCHAR2(100)) ;
    PROMPT SITA_ADDRESSS_NT...
    CREATE OR REPLACE TYPE SITA_ADDRESSES_NT AS TABLE OF
    SITA_ADDRESS_TY ;
    Using this nested table we have created the table,
    UMS_SITA_ADDRESS
    CREATE TABLE UMS_SITA_ADDRESS (
    COMPANY_CODE VARCHAR2 (6) NOT NULL,
    AIRLINE_CODE VARCHAR2 (6) NOT NULL,
    DESTINATION VARCHAR2 (6) NOT NULL,
    SITA_ADDRESS SITA_ADDRESSES_NT)
    TABLESPACE EKUMDAT
    PCTFREE 5
    PCTUSED 40
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    NEXT 64K
    PCTINCREASE 0
    MINEXTENTS 1
    MAXEXTENTS 505
    FREELISTS 1 FREELIST GROUPS 1 )
    NOCACHE
    NESTED TABLE SITA_ADDRESS STORE AS UMSNT_SITA_ADDRESS ;
    PROMPT SYNONYM SITA_ADDRESS_TY...
    CREATE PUBLIC SYNONYM SITA_ADDRESS_TY FOR SITA_ADDRESS_TY
    PROMPT SYNONYM SITA_ADDRESSES_NT...
    CREATE PUBLIC SYNONYM SITA_ADDRESSES_NT FOR SITA_ADDRESSES_NT
    PROMPT UMS_SITA_ADDRESS...
    CREATE PUBLIC SYNONYM UMS_SITA_ADDRESS FOR UMS_SITA_ADDRESS
    Granting Privileges
    PROMPT SITA_ADDRESS_TY...
    GRANT EXECUTE ON SITA_ADDRESS_TY TO COPY
    PROMPT SITA_ADDRESSS_NT...
    GRANT EXECUTE ON SITA_ADDRESSES_NT TO COPY
    PROMPT UMS_SITA_ADDRESS...
    GRANT ALL ON UMS_SITA_ADDRESS TO COPY
    When I connect to copy and desc UMS_SITA_ADDRESS, the structure
    is
    SQL> desc ums_sita_address
    Name Null? Type
    COMPANY_CODE NOT NULL VARCHAR2(6)
    AIRLINE_CODE NOT NULL VARCHAR2(6)
    DESTINATION NOT NULL VARCHAR2(6)
    SITA_ADDRESS
    OWNR.SITA_ADDRESSES_NT
    Why is it so??. Even though I have a synonym for
    SITA_ADDRESSES_NT, it is not referencing the synonym but instead
    refer the OWNR.SITA_ADDRESSES_NT
    Because of this when I try to insert into ums_sita_address(in
    schema COPY), it is giving the following error,
    SQL> insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_NT());
    insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_NT())
    ERROR at line 1:
    ORA-00932: inconsistent datatypes
    But when the same connect to OWNR and try to insert with the
    same stmt, it is inserting...
    Our middle tier can connect only to COPY schema alone..Is there
    anything to be done in the DBA side to achieve this??.
    Please help from your valuabe experience...Or can you ask your
    collegues if they have got a soln to this probs..We are stucked
    with this...
    Thanks
    Priya

    Hi
    I am not sure but maybe you need to use this command:
    SQL> insert into ums_sita_address values
    ('EK','EK','DXB',SITA_ADDRESSES_TY());
    SITA_ADDRESSES_TY() instead SITA_ADDRESSES_NT
    Regards

  • Nested table type in object view on 8.1.7

    Object views seem to be the ideal way to deliver XML datagrams from database queries with nested data.
    I need to create a datagram that contains nested data within another nested set of data eg. a family has many people, each person may have many hobbies.
    The following code taken from Oracle documentation would create the Types I need, but this does not work on 8.1.7 (gets PLS-00534 error). Can someone advise if nested tables within a table type is a new Oracle 9 feature?
    CREATE TYPE project_t AS OBJECT
    ( projname VARHCAR2(20)
    , mgr VARHCAR2(20));
    CREATE TYPE nt_project_t AS TABLE OF project_t;
    CREATE TYPE emp_t AS OBJECT
    ( ename VARCHAR2(20)
    , salary NUMBER
    , deptname VARHCAR2(20)
    , projects nt_project_t);
    CREATE TYPE nt_emp_t AS TABLE OF emp_t;
    CREATE TYPE dept_t AS OBJECT
    ( deptno NUMBER
    , deptname VARHCAR2(20)
    , emps nt_emp_t);
    Thks, Matt. (asked same question in XML forum but maybe more appropriate here).
    null

    Matthew,
    Value-based multi-level collections, such as the one you have here, were not supported in 8.1.7. You have two choices:
    1. Upgrade to 9i to take advantage of value-based multi-level collections (see http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88878/adobjbas.htm#462243), type inheritance, type evolution and other new features.
    2. Use REFs in 8.1.7 to build a reference-based multi-level collections (see http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/appdev.817/a76976/adobjdes.htm#446229).
    Regards,
    Geoff

  • ROWNUM equivalent for Nested Tables?

    Is there an equivalent to the ROWNUM pseudocolumn for a nested table such that something like this...
    WITH driver_data AS
      (SELECT 1 AS id, sys.dbms_debug_vc2coll('a','b','c') AS val FROM dual
      UNION ALL
      SELECT 2 AS id, sys.dbms_debug_vc2coll('x','y','z') AS val FROM dual)
    SELECT t1.id,
      --t2.rownum as pos,
      t2.column_value AS val
    FROM driver_data t1,
         TABLE(t1.val) t2 ;
    ID     VAL
    1     a
    1     b
    1     c
    2     x
    2     y
    2     z...would return something like this...
    ID     VAL  POS
    1     a      1
    1     b      2
    1     c      3
    2     x      1
    2     y      2
    2     z      3

    ABB wrote:
    But the OP now has two collections per row of data, not one, as he showed above, so it becomes more complicated.Yes, it does. But still solvable:
    with t1 as (
                select  t1.*,
                        rownum rn_main
                  from  driver_data t1
         t2 as (
                select  id,
                        val1,
                        rn_main,
                        row_number() over(partition by rn_main order by rn_nested) pos
                  from  (
                         select  id,
                                 column_value val1,
                                 rn_main,
                                 rownum rn_nested
                           from  t1,
                           table(val1)
         t3 as (
                select  id,
                        val2,
                        rn_main,
                        row_number() over(partition by rn_main order by rn_nested) pos
                  from  (
                         select  id,
                                 column_value val2,
                                 rn_main,
                                 rownum rn_nested
                           from  t1,
                           table(val2)
    select  nvl(t2.id,t3.id) id,
            val1,
            val2,
            nvl(t2.pos,t3.pos) pos
      from  t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
      order by nvl(t2.rn_main,t3.rn_main),
               nvl(t2.pos,t3.pos)
    SQL> create table driver_data(
      2                           id number,
      3                           val1 sys.dbms_debug_vc2coll,
      4                           val2 sys.dbms_debug_vc2coll
      5                          )
      6    nested table val1 store as val1_tbl,
      7    nested table val2 store as val2_tbl
      8  /
    Table created.
    SQL> insert
      2    into driver_data
      3    SELECT  1 id,
      4            sys.dbms_debug_vc2coll('c','b','a') val1,
      5            sys.dbms_debug_vc2coll('k','u') val2
      6      FROM  dual
      7   UNION ALL
      8    SELECT  2 id,
      9            sys.dbms_debug_vc2coll('z','y','x') val1,
    10            sys.dbms_debug_vc2coll('n','e','j','t') val2
    11      FROM  dual
    12   UNION ALL
    13    SELECT  1 id,
    14            sys.dbms_debug_vc2coll('c','b','a') val1,
    15            sys.dbms_debug_vc2coll('k','u') val2
    16      FROM  dual
    17   UNION ALL
    18    SELECT  2 id,
    19            sys.dbms_debug_vc2coll('z','y','x') val1,
    20            sys.dbms_debug_vc2coll('n','e','j','t') val2
    21      FROM  dual
    22  /
    4 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> column val1 format a10
    SQL> column val2 format a10
    SQL> with t1 as (
      2              select  t1.*,
      3                      rownum rn_main
      4                from  driver_data t1
      5             ),
      6       t2 as (
      7              select  id,
      8                      val1,
      9                      rn_main,
    10                      row_number() over(partition by rn_main order by rn_nested) pos
    11                from  (
    12                       select  id,
    13                               column_value val1,
    14                               rn_main,
    15                               rownum rn_nested
    16                         from  t1,
    17                         table(val1)
    18                      )
    19             ),
    20       t3 as (
    21              select  id,
    22                      val2,
    23                      rn_main,
    24                      row_number() over(partition by rn_main order by rn_nested) pos
    25                from  (
    26                       select  id,
    27                               column_value val2,
    28                               rn_main,
    29                               rownum rn_nested
    30                         from  t1,
    31                         table(val2)
    32                      )
    33             )
    34  select  nvl(t2.id,t3.id) id,
    35          val1,
    36          val2,
    37          nvl(t2.pos,t3.pos) pos
    38    from  t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
    39    order by nvl(t2.rn_main,t3.rn_main),
    40             nvl(t2.pos,t3.pos)
    41  /
            ID VAL1       VAL2              POS
             1 c          k                   1
             1 b          u                   2
             1 a                              3
             2 z          n                   1
             2 y          e                   2
             2 x          j                   3
             2            t                   4
             1 c          k                   1
             1 b          u                   2
             1 a                              3
             2 z          n                   1
            ID VAL1       VAL2              POS
             2 y          e                   2
             2 x          j                   3
             2            t                   4
    14 rows selected.
    SQL> SY.

  • Help needed  for nested  table

    Hi ,
    I have a function which returns nested table as result .The nested table can sometimes be null.So when i reference the first and last value for a loop, when table is null , then i am getting numeric value error .So i added a check on the nested table as below
    if n_table is empty then
    exit;
    end if;
    for i in n_table.first ..n_table.last
    loop
    select count(1) into_count
    from x where rate=n_table(i);
    end loop;
    Now iam getting a message as" DANGLING NOT NULL OF".Though it gets compiled .iam getting everytime when i first compile it .Please let me know what should i add to prevent this

    Null and empty are two different things. Also please post the complete error message.
    Notice the difference between
    DECLARE
        v_tab INTEGER_TT;
    BEGIN
        IF v_tab IS NOT NULL THEN
            FOR i IN v_tab.FIRST..v_tab.LAST LOOP
                DBMS_OUTPUT.PUT_LINE('Loop iteration ' || i);
            END LOOP;
        END IF;
    END;and
    DECLARE
        v_tab INTEGER_TT := INTEGER_TT();
    BEGIN
        IF v_tab IS NOT EMPTY THEN
            FOR i IN v_tab.FIRST..v_tab.LAST LOOP
                DBMS_OUTPUT.PUT_LINE('Loop iteration ' || i);
            END LOOP;
        END IF;
    END;

  • XML Type - ExtractValue for Nested Tables

    Hi all,
    PROCEDURE TESTING
    IS
    v_xml CLOB := '<EMPLOYEE><RECORD><EMPID>12</EMPID><EMPNAME>ROCK</EMPNAME></RECORD><RECORD><EMPID>13</EMPID>13<EMPNAME>PETER</EMPNAME></RECORD><RECORD><EMPID>14</EMPID><EMPNAME>JOHN</EMPNAME></RECORD></EMPLOYEE>';
    BEGIN
    FOR i IN
    (SELECT EXTRACTVALUE (indv_xml, 'RECORD/EMPID') eid,EXTRACTVALUE (indv_xml, 'RECORD/EMPNAME') ename
    FROM (SELECT VALUE (v) indv_xml
    FROM (SELECT XMLTYPE (v_xml) main_xml
    FROM DUAL),
    TABLE
    (XMLSEQUENCE
    (EXTRACT
    (main_xml,
    'EMPLOYEE/RECORD'
    ) v))
    LOOP
    insert into employee values(eid,ename);
    END LOOP;
    END;
    Now i have the xml like this:-
    '<EMPLOYEE>
    <EMPTYPE>
    <TYPEID>121</TYPEID>
    <ROW><EMPID>12</EMPID><EMPNAME>ROCK</EMPNAME></ROW>
    <ROW><EMPID>13</EMPID>13<EMPNAME>PETER</EMPNAME></ROW>
    </EMPTYPE>
    <EMPTYPE>
    <TYPEID>122</TYPEID>
    <ROW><EMPID>14</EMPID><EMPNAME>JOHN</EMPNAME></ROW>
    </EMPTYPE>
    </EMPLOYEE>'
    In this case, I have populate into two tables first EMP_TYPE (typeid - PK) and EMPLOYEE(EID,ENAME,TYPEID -FK)...
    Pls provide me some sample code.
    Thanks
    Simbhu

    Hi,
    I have a similar requirement, where i need to extract a particular segment from an xml doc, but am getting errors:
    The XML Doc is :
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <Code39Response> <Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
    </Code39Response>
    </soap:Body>
    </soap:Envelope>
    select XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <Code39Response> <Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
    </Code39Response>
    </soap:Body>
    </soap:Envelope>') from dual
    does NOT give any error. BUT
    SELECT VALUE(v) xml_data
    FROM (select XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <Code39Response>
    <Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
    </Code39Response>
    </soap:Body>
    </soap:Envelope>') main_xml from dual), TABLE(xmlsequence(extract(main_xml,'soap:Envelope/soap:Body/child::node()'))) v
    Gives me the error below:
    ORA-31011: XML Parsing Failed
    ORA-19202: Error occured in XML Parsing
    LPX-00601: Invalid token in '<soap:Envelope/soap:Body'
    31011.00000 - "XML Parsing Failed"
    Am i doing something wrong?
    Thanks
    Ashish

  • How to assign values into nested table type in plsql

    hi all,
    I feel some what difficult to return user defined types from plsql function and procedures .
    Can any one help me to learn this .
    Version details are as follow
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL>
    create or replace type emp_names_nt is table of varchar2(100);
    /* Formatted on 2012/04/05 15:23 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE FUNCTION get_emp_names
       RETURN emp_names_nt
    IS
       CURSOR ec
       IS
          SELECT ename
            FROM emp;
       v_emp_names   emp_names_nt := emp_names_nt ();
    BEGIN
       FOR i IN ec
       LOOP
          v_emp_names.EXTEND ();
          v_emp_names (i) := i.ename;
       END LOOP;
       RETURN v_emp_names;
    END;
    Error :
    PL/SQL: Statement ignored
    PLS-00382: expression is of wrong typeThanks in advance .............
    Thanks,
    P Prakash

    CREATE OR REPLACE FUNCTION get_emp_names
       RETURN emp_names_nt
    IS
       CURSOR ec
       IS
          SELECT ename
            FROM scott.emp;
       v_emp_names   emp_names_nt := emp_names_nt();
       cnt  number:=1;
    BEGIN
       FOR i IN ec
       LOOP
          v_emp_names.EXTEND;
          v_emp_names(cnt) := i.ename;
          cnt:=cnt+1;
       END LOOP;
       RETURN v_emp_names;
    END;
    show errors

Maybe you are looking for