Collections stored as Nested tables

I have created a Table with XMLTYPE column and the
column is defined as Object against a registered Schema.
I have also created nested tables for all collection types
and created appropriate indexes on the Nested tables
based on Nested_table_Id and array_index.
CREATE TABLE STATEMENT_DATA
TEST SYS.XMLTYPE
XMLTYPE COLUMN TEST STORE AS OBJECT RELATIONAL
XMLSCHEMA "StatementData.xsd"
ELEMENT "StatementData"
varray TEST."XMLDATA"."MessagePayload"."BillDeterminant"
STORE AS table BillDeterminant
( varray "AttributeList" STORE AS table BillDtr_AttrList,
varray "ChargeProfileData" STORE AS table BillDtr_ProfData )
varray TEST."XMLDATA"."MessagePayload"."MarketStatement"
STORE AS table MarketStatement
(varray "MarketStatementLineItem" STORE AS table marketlineitm
( varray "PassThroughBill"."AttributeList" STORE AS table Lineitm_ChargeProf_AttrList,
     varray "PassThroughBill"."ChargeProfile" STORE AS table Lineitm_ChargeProfile
     (varray "ChargeProfileData" STORE AS table ChargeProfileData),
     varray "AttributeList" STORE AS table Lineitm_AttributeList),
     varray "RTO" STORE AS table Rto
     (varray "ErpAddress" STORE AS table rto_ErpAddress,
          varray "ErpPerson" STORE AS table rto_Erpperson
          (varray "ErpTelephoneNumber" STORE AS table rto_ErpTelephoneNumber)) ,
     varray "Customer" STORE AS table Customer
     (varray "ErpAddress" STORE AS table Cust_ErpAddress,
          varray "ErpPerson" STORE AS table cust_Erpperson
          (varray "ErpTelephoneNumber" STORE AS table cust_ErpTelephoneNumber)) ,
varray "ActivityRecord" STORE AS table ActivityRecord)
Sample Index :
CREATE UNIQUE INDEX MARKETLINEITM_indx1 ON MARKETLINEITM d
( d.NESTED_TABLE_ID,d.array_index);
Now when I tried to execute a sample query involving some of the
nested tables , Explain Plan shows that it is not using the indexes
I have created.
The following parameters are also set in the Database.
query_rewrite_enabled : TRUE
query_rewrite_integrity : TRUSTED.
I am using Oracle 9.2.0.5.0.
Can somebody tell me if I am missing something?
Thanks,
Arun

Thanks for the reply. XMPTYPE based column is not using the
indexes even after gathering Index statistics. However the Statistics
gathering is helping queries based on XMLTYPE based tables.
Any suggestion for XMLTYPE based columns ? Has anybody
been able to successfully use the indexes in 10g ?
Arun

Similar Messages

  • Data pump import error with nested tables

    So the problem is somewhat long :)
    Actually the problems are two - why and how oracle are treating OO concept and why data pump doesn't work?
    So scenario for the 1st one:
    1) there is object type h1 and table of h1
    2) there is unrelated object type row_text and table of row_text
    3) there is object type h2 under h1 with attribute as table of row_text
    4) there is table tab1 with column b with data type as table of h1. Of course column b is stored as nested table.
    So how do you think - how many nested tables Oracle will create? The correct answer is 2. One explicitly defined and one hidden with system
    generated name for the type h2 which is under type h1. So the question is WHY? Why if I create an instance of supertype Oracle tries to adapt
    it for the subtype as well? Even more if I create another subtype h3 under h1 another hidden nested table appears.
    This was the first part.
    The second part is - if I do schema export and try to import it in another schema I got error saying that oracle failed to create storage table for
    nested table column b. So the second question is - if Oracle has created such a mess with hidden nested tables how to import/export to another
    schema?
    Ok and here is test case to demonstrate problems above:
    -- creating type h1 and table of it
    SQL> create or replace type h1 as object (a number)
      2  not final;
      3  /
    Type created.
    SQL> create or replace type tbl_h1 as table of h1;
      2  /
    Type created.
    -- creating type row_text and table of it
    SQL> create or replace type row_text as object (
      2    txt varchar2(100))
      3  not final;
      4  /
    Type created.
    SQL> create or replace type tbl_row_text as table of row_text;
      2  /
    Type created.
    -- creating type h2 as subtype of h1
    SQL> create or replace type h2 under h1 (some_texts tbl_row_text);
      2  /
    Type created.
    SQL> create table tab1 (a number, b tbl_h1)
      2  nested table b
      3  store as tab1_nested;
    Table created.
    -- so we have 2 nested tables now
    SQL> select table_name, parent_table_name, parent_table_column
      2  from user_nested_tables;
    TABLE_NAME                     PARENT_TABLE_NAME
    PARENT_TABLE_COLUMN
    SYSNTfsl/+pzu3+jgQAB/AQB27g==  TAB1_NESTED
    TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"
    TAB1_NESTED                    TAB1
    B
    -- another subtype of t1
    SQL> create or replace type h3 under h1 (some_texts tbl_row_text);
      2  /
    Type created.
    -- plus another nested table
    SQL> select table_name, parent_table_name, parent_table_column
      2  from user_nested_tables;
    TABLE_NAME                     PARENT_TABLE_NAME
    PARENT_TABLE_COLUMN
    SYSNTfsl/+pzu3+jgQAB/AQB27g==  TAB1_NESTED
    TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"
    SYSNTfsl/+pz03+jgQAB/AQB27g==  TAB1_NESTED
    TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H3")."SOME_TEXTS"
    TAB1_NESTED                    TAB1
    B
    SQL> desc "SYSNTfsl/+pzu3+jgQAB/AQB27g=="
    Name                                      Null?    Type
    TXT                                                VARCHAR2(100)OK let it be and now I'm trying to export and import in another schema:
    [oracle@xxx]$ expdp gints/xxx@xxx directory=xxx dumpfile=gints.dmp logfile=gints.log
    Export: Release 11.2.0.1.0 - Production on Thu Feb 4 22:32:48 2010
    <irrelevant rows skipped>
    Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    . . exported "GINTS"."TAB1"                                  0 KB       0 rows
    . . exported "GINTS"."SYSNTfsl/+pz03+jgQAB/AQB27g=="         0 KB       0 rows
    . . exported "GINTS"."TAB1_NESTED"                           0 KB       0 rows
    . . exported "GINTS"."SYSNTfsl/+pzu3+jgQAB/AQB27g=="         0 KB       0 rows
    Master table "GINTS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
    ******************************************************************************And now import. In order to create types transformation of OIDs is applied and also remap_schema
    Although it fails to create the table.
    [oracle@xxx]$ impdp gints1/xxx@xxx directory=xxx dumpfile=gints.dmp logfile=gints_imp.log remap_schema=gints:gints1 transform=OID:n
    Import: Release 11.2.0.1.0 - Production on Thu Feb 4 22:41:48 2010
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Release 11.2.0.1.0 - Production
    Master table "GINTS1"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "GINTS1"."SYS_IMPORT_FULL_01":  gints1/********@xxx directory=xxx dumpfile=gints.dmp logfile=gints_imp.log remap_schema=gints:gints1 transform=OID:n
    Processing object type SCHEMA_EXPORT/USER
    ORA-31684: Object type USER:"GINTS1" already exists
    Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
    Processing object type SCHEMA_EXPORT/ROLE_GRANT
    Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
    Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
    Processing object type SCHEMA_EXPORT/TABLE/TABLE
    ORA-39083: Object type TABLE:"GINTS1"."TAB1" failed to create with error:
    ORA-02320: failure in creating storage table for nested table column B
    ORA-00904: : invalid identifier
    Failing sql is:
    CREATE TABLE "GINTS1"."TAB1" ("A" NUMBER, "B" "GINTS1"."TBL_H1" ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
    Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    ORA-39083: Object type INDEX_STATISTICS failed to create with error:
    ORA-01403: no data found
    ORA-01403: no data found
    Failing sql is:
    DECLARE I_N VARCHAR2(60);   I_O VARCHAR2(60);   c DBMS_METADATA.T_VAR_COLL;   df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; BEGIN  DELETE FROM "SYS"."IMPDP_STATS";   c(1) :=   DBMS_METADATA.GET_STAT_COLNAME('GINTS1','TAB1_NESTED',NULL,'TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H2")."SOME_TEXTS"',1);  DBMS_METADATA.GET_STAT_INDNAME('GINTS1','TAB1_NESTED',c,1,i_o,i_n);   INSERT INTO "
    ORA-39083: Object type INDEX_STATISTICS failed to create with error:
    ORA-01403: no data found
    ORA-01403: no data found
    Failing sql is:
    DECLARE I_N VARCHAR2(60);   I_O VARCHAR2(60);   c DBMS_METADATA.T_VAR_COLL;   df varchar2(21) := 'YYYY-MM-DD:HH24:MI:SS'; BEGIN  DELETE FROM "SYS"."IMPDP_STATS";   c(1) :=   DBMS_METADATA.GET_STAT_COLNAME('GINTS1','TAB1_NESTED',NULL,'TREAT(SYS_NC_ROWINFO$ AS "GINTS"."H3")."SOME_TEXTS"',1);  DBMS_METADATA.GET_STAT_INDNAME('GINTS1','TAB1_NESTED',c,1,i_o,i_n);   INSERT INTO "
    Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    Job "GINTS1"."SYS_IMPORT_FULL_01" completed with 4 error(s) at 22:41:52So any idea how to make export/import of such tables?
    TIA
    Gints

    Tom Kyte has said it repeatedly ... I will repeat it here for you.
    The fact that Oracle allows you to build object tables is not an indication that you should.
    Store your data relationally and build object_views on top of them.
    http://www.morganslibrary.org/reference/object_views.html
    If you model properly, and store properly, you don' have any issues.

  • Insert with Nested Table

    Hi,
    I have a table called time_slots
    CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
    CREATE TABLE time_slots
    time_code VARCHAR2(50),
    TIME_SLOT TYPE_TIMESLOTS
    NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS
    I have a SQL which returns multiple rows for each period_code, as I need to insert data into the above table based on a source table.
    But I don't know how to do this.
    For example, I have a SQL which returns
    Time Code Slots
    OPENH 09:00
    OPENH 10:00
    OPENH 11:00
    CLOSH 12:00
    CLOSH 13:00
    CLOSH 14:00
    NOH 15:00
    NOH 16:00
    So, I want the INSERT statement to insert 3 rows into the table and the slots collected into the nested table. I don't know how to merge the 3 rows that relate to OPENH into 1 row with a collection for the slots.
    I want to do this in SQL rather than PL/SQL.
    Please help.
    Thanks
    M

    To insert from a select statement, you can use the collect function to group the time slots into your collection for each distinct time code. See below. I've created a view called "sample_data" just to make the examples easier.
    SQL> CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
      2  /
    Type created.
    SQL> CREATE TABLE time_slots
      2  (
      3  time_code VARCHAR2(50),
      4  time_slot TYPE_TIMESLOTS
      5  )
      6  NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS;
    Table created.
    SQL> CREATE VIEW sample_data
      2  AS
      3     SELECT 'OPENH' AS time_code, TO_DATE('09:00','HH24:MI') AS time_slot FROM dual
      4     UNION ALL
      5     SELECT 'OPENH' AS time_code, TO_DATE('10:00','HH24:MI') AS time_slot FROM dual
      6     UNION ALL
      7     SELECT 'OPENH' AS time_code, TO_DATE('11:00','HH24:MI') AS time_slot FROM dual
      8     UNION ALL
      9     SELECT 'CLOSH' AS time_code, TO_DATE('12:00','HH24:MI') AS time_slot FROM dual
    10     UNION ALL
    11     SELECT 'CLOSH' AS time_code, TO_DATE('13:00','HH24:MI') AS time_slot FROM dual
    12     UNION ALL
    13     SELECT 'CLOSH' AS time_code, TO_DATE('14:00','HH24:MI') AS time_slot FROM dual
    14     UNION ALL
    15     SELECT 'NOH' AS time_code, TO_DATE('15:00','HH24:MI') AS time_slot FROM dual
    16     UNION ALL
    17     SELECT 'NOH' AS time_code, TO_DATE('16:00','HH24:MI') AS time_slot FROM dual
    18     ;
    View created.
    SQL> SELECT time_code
      2  ,      CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
      3  FROM   sample_data
      4  GROUP  BY
      5         time_code;
    TIME_CODE TIME_SLOT
    CLOSH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    NOH       TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
    OPENH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    SQL> INSERT INTO time_slots (time_code, time_slot)
      2  SELECT time_code
      3  ,      CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
      4  FROM   sample_data
      5  GROUP  BY
      6         time_code;
    3 rows created.
    SQL> SELECT * FROM time_slots;
    TIME_CODE TIME_SLOT
    CLOSH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    NOH       TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
    OPENH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    SQL> SELECT t.time_code
      2  ,      TO_CHAR(nt.column_value, 'HH24:MI') AS time_slot
      3  FROM   time_slots         t
      4  ,      TABLE(t.time_slot) nt;
    TIME_CODE TIME_SLOT
    CLOSH     12:00
    CLOSH     13:00
    CLOSH     14:00
    NOH       15:00
    NOH       16:00
    OPENH     09:00
    OPENH     10:00
    OPENH     11:00
    8 rows selected.Regards

  • Select from a collection of collections SELECT - CAST - MULTISET - TABLE

    Does someone have a suggestion for the SELECT statement which is performing a CAST?
    I am on Oracle 10.2.0.1.0. The goal is to take a collection of a nested table and order it by color, then descr, then grown_by, saving it into an ordered collection (v_List2). Am getting error with ORA-22907 Invalid cast to a type that is not a nested table.
    CREATE OR REPLACE TYPE     ot_fruit
    AS OBJECT
        descr            VARCHAR2(100)
       ,color          VARCHAR2(50)
       ,grown_by          VARCHAR2(50) 
    CREATE OR REPLACE TYPE tab_fruitList AS TABLE OF ot_fruit;
    CREATE OR REPLACE TYPE     ot_tab_fruit
    AS OBJECT
        fruit            tab_fruitList
    DECLARE
       v_List  ot_tab_fruit := ot_tab_fruit(tab_fruitList(ot_fruit('apple','red','tree'),
                                                          ot_fruit('blueberry','blue','bush')
       v_List2 ot_tab_fruit := ot_tab_fruit(tab_fruitList());
    BEGIN
      SELECT CAST ( MULTISET ( SELECT * FROM TABLE(v_List)
                               ORDER BY 2, 3, 1
                               <b> -- This compiles with ORA-22907 error
                                  AS  ot_tab_fruit</b>
                  ) INTO v_List2
      FROM DUAL;
      FOR i IN v_List2.FIRST..v_List2.LAST
      LOOP  
         DBMS_OUTPUT.PUT_LINE('i='||i||' descr='||v_List2(i).fruit.descr ||' color='||
               v_List2(i).fruit.color||' grown_by='||v_List2(i).fruit.grown_by);
      END LOOP;
    END;Thanks, Kate
    Message was edited by:
    johnsok

    This solution, which works perfectly by the way, came from Avi Abrami. I've highlighted the necessary changes to make the SELECT of a collection of objects work properly.
    create or replace type OT_FRUIT as object (
      DESCR     varchar2(100)
    ,COLOR     varchar2(50)
    ,GROWN_BY  varchar2(50)
    create or replace type TAB_FRUITLIST as table of OT_FRUIT;
    create or replace type OT_TAB_FRUIT as object (
      FRUIT  TAB_FRUITLIST
    DECLARE
       v_List  ot_tab_fruit := ot_tab_fruit(tab_fruitList(ot_fruit('apple','red','tree'),
                                                          ot_fruit('blueberry','blue','bush')
       v_List2 ot_tab_fruit := ot_tab_fruit(tab_fruitList());
    BEGIN
      SELECT CAST ( MULTISET ( SELECT * FROM TABLE(v_List.fruit)
                               ORDER BY 2, 3, 1
                                  AS tab_fruitlist
                  ) INTO v_List2.fruit
      FROM DUAL;
      FOR i IN v_List2.fruit.FIRST..v_List2.fruit.LAST
      LOOP
         DBMS_OUTPUT.PUT_LINE('i='||i||' descr='||v_List2.fruit(i).descr ||' color='||
               v_List2.fruit(i).color||' grown_by='||v_List2.fruit(i).grown_by);
      END LOOP;
    END;
    /

  • Nested table collection in select query "in clause" taking long time

    create or replace type t_circuitids is table of varchar2(100);
    --Below anonymous block keeps on running and never ends
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (v_circuitid));
    END;
    --I got the issue, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" which is used in above code is responsible for this.
    --Same code works fine in Development and Test environments, But in prod it keeps on running
    --I solved this issue by creating a temp table, loading all values in collection into the temp table and using that temp table in "in clause"    "
    --Can any one answer why its behaving like this when i use collection in where clause?
    --I am using Oracle 9i

    Below is the code i used
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (ccard(v_circuitid)));
    END;
    And got below error
    ORA-06550: line 27, column 5:
    PL/SQL: ORA-00906: missing left parenthesis
    ORA-06550: line 24, column 4:
    PL/SQL: SQL Statement ignored

  • 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.

  • Storing data in data bse using nested tables

    using nested tables data can be stored in data base or not.
    if yes i need simple example for taht and how to retireve the data from data base.

    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11822/adobjvew.htm#ADOBJ00511
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/composites.htm#LNPLS99981

  • Query Nested table (collection)

    I try to query on a nested table (collection).
    How ever, I get a 600 error.
    Is there any way to reuse the result of query in the store procedure?
    SQL&gt; DECLARE
    2 TYPE T_PER_ID IS TABLE OF PERIOD.PER_ID%TYPE;
    3 V_EXP_PER_ID T_PER_ID;
    4 V_EXP_PER_ID2 T_PER_ID;
    5 BEGIN
    6 SELECT PER_ID BULK COLLECT INTO V_EXP_PER_ID FROM PERIOD;
    7 SELECT * BULK COLLECT INTO V_EXP_PER_ID2 FROM TABLE(V_EXP_PER_ID);
    8 END;
    9 /
    DECLARE
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL
    execution], [], [], [], [], [], []
    ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [],
    ORA-06553: PLS-801: internal error [0]

    Oracle Version 8.1.6

  • What is Varray,Nested tables,Collections,Pragma?

    Hi,
    what is Varray,Nested tables,Collections,Pragma?
    and in Which Situations will We Use this?.
    Anyone having any dea regarding this?

    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    http://awads.net/wp/2006/03/01/pragmatism-in-oracle-plsqlKhurram

  • 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 =\

  • How to create Nested table in oracle stored procedure(Temp Table)

    Hi
    I am creating Nested table in stored procedure(Temp Table)
    type t_v_tbl_rec is record(cumid number,col1 varchar(50),col2 varchar(50),col3 varchar(50),col4 varchar(50),col5 varchar(50),col6 varchar(50));
    type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    V_V_TBL t_v_tbl;
    But i can't insert value in to this temp table
    Plz help me

    What is problem?
    SQL>declare
      2      type t_v_tbl_rec is record( cumid number,
      3                                  col1 varchar(50),
      4                                  col2 varchar(50),
      5                                  col3 varchar(50),
      6                                  col4 varchar(50),
      7                                  col5 varchar(50),
      8                                  col6 varchar(50) );
      9      type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    10      v_v_tbl t_v_tbl;
    11  begin
    12      v_v_tbl(1).cumid := 1;
    13      dbms_output.put_line(v_v_tbl(1).cumid);
    14  end;
    15  /
    1
    PL/SQL procedure successfully completed.

  • Collection -- Nested tables

    Hi,
    I am trying to use collections as nested tables from below mentioned procedure, but facing a problem of getting only last rows.
    Any help would be appreciated.
    +CREATE OR REPLACE PROCEDURE pr_collection
    AS
    TYPE type_num IS TABLE OF NUMBER;
    t_num type_num;
    TYPE type_char IS TABLE OF VARCHAR2 (20);
    t_char type_char;
    BEGIN
    FOR i IN (SELECT eid, nm
    FROM emp)
    LOOP
    t_num := type_num (i.eid);
    t_char := type_char (i.nm);
    DBMS_OUTPUT.put_line (i.eid || i.nm);
    END LOOP;
    DBMS_OUTPUT.put_line (t_num.COUNT);
    DBMS_OUTPUT.put_line (t_num.FIRST);
    DBMS_OUTPUT.put_line (t_num.LAST);
    FORALL J IN T_NUM.FIRST.. T_NUM.LAST
    INSERT INTO TEST
    VALUES (t_num (J), t_char (J));
    COMMIT;
    END;
    /+
    Output :
    1
    1
    1
    Thanks in Advance,
    Prashant

    Hi,
    It's normal, you get only the last element because of the following
    LOOP
        t_num := type_num (i.eid);
        t_char := type_char (i.nm);
    END LOOP;Each time you call the nested table constructor with the new element, so the previous elements are lost. The correct way of doing this is to call once the constructor before the LOOP and then call the EXTEND method inside the loop in order to make room available for each new element.
    Therefore, something like this:
    CREATE OR REPLACE PROCEDURE pr_collection AS
        TYPE type_num IS TABLE OF NUMBER;
        t_num type_num;
        t_num_idx PLS_INTEGER := 1;
        TYPE type_char IS TABLE OF VARCHAR2 (20);
        t_char type_char;
        t_char_idx PLS_INTEGER := 1;
    BEGIN
        t_char := type_char();
        t_num := type_num();
        FOR i IN (SELECT eid, nm FROM emp) LOOP
            t_num.EXTEND;
            t_num(t_num_idx) := i.eid;
            t_num_idx := t_num_idx + 1;
            t_char.EXTEND;
            t_char(t_char_idx) := i.nm;
            t_char_idx := t_char_idx + 1;
            DBMS_OUTPUT.put_line (i.eid || i.nm);
        END LOOP;
        DBMS_OUTPUT.put_line (t_num.COUNT);
        DBMS_OUTPUT.put_line (t_num.FIRST);
        DBMS_OUTPUT.put_line (t_num.LAST);
        FORALL J IN T_NUM.FIRST.. T_NUM.LAST
            INSERT INTO TEST VALUES (t_num (J), t_char (J));
        COMMIT;
    END;That being said, why do you add elements one by one, it is slow, why not using BULK COLLECT?
    Regards,
    Dariyoosh

  • Storing data in data abse using nested  table

    using nested table is it possible 2 store data in data base .give me simple example how tos tore data in data abse usingnested tables.and how to retieve it from data abse.

    See: http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:410619303624

  • Associative Array to Nested Table: Anything faster?

    (First Post! Some ASP.NET references, but I think this really is a PL/SQL question)
    I work on a team that runs an Oracle instance for data warehousing and reporting along with an ASP.NET based website for display.
    Sometimes, I may want to have many parameters come in and only show records that match those parameters. For example, I may want to show all employees who are Managers or Developers and not show employees who are Accountants or Scientists. Typically, I send a parameter into my PL/SQL stored procedures as an associative array (as declared in my package specification). Once in the procedure, I convert that associative array into another associative array (as a user created SQL type) and then I'm able to use it like a nested table to join on.
    My question is: in your experience, is there any way to get around this type conversion or another faster way?
    For example:
    -- Create the sql type
    CREATE OR REPLACE TYPE DIM.sql_string_table AS TABLE OF VARCHAR2(255);
    --pretend that this works and it's in a package body
    declare
    type string_table is table of varchar2(255) index by binary_integer;
    l_job_types string_table; -- Keep in mind I'd normally be sending this via ASP.NET
    l_job_types_nested sql_string_table := sql_string_table();
    begin
    -- Add some data
    l_job_types(0) := 'Manager';
    l_job_types(1) := 'Developer';
    -- Do the conversion
    for i in l_job_types.first .. l_job_types.last
    loop
    l_job_types_nested.extend;
    l_job_types_nested(l_job_types_nested.count) := l_job_types(i);
    end loop;
    -- get some data out (we're pretending)
    open fake_ref_cursor for
    Select e.*
    from employees e,
    the(select cast(l_job_types_nested as sql_string_table) from dual) jobs_types_wanted
    where e.type = value(jobs_types_wanted);
    end;
    The result would be all employees whose have a type that was input into the l_job_types associatve array.
    See: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061
    for additional reference

    > I convert that associative array into another associative array (as a user created SQL type)
    Just so we're clear, Oracle use the term 'associative array' to refer to the exclusively PL/SQL sparse collection type ("table of x index by pls_integer" etc) as distinct from the common nested table collection type.
    Also I could be wrong but I think
    SELECT ..
    FROM   the(select cast(l_job_types_nested as sql_string_table) from dual) jobs_types_wantedis generally the same as
    SELECT ..
    FROM   TABLE(l_job_types_nested) jobs_types_wantedthough "SELECT *" and implicitly collection casting don't always mix. The "THE()" syntax is deprecated.

  • How to use nested table values in IN expression?

    Hi!
    Can someone please give me a hint to the correct syntax for this:
    declare
    TYPE numtable is table of number;
    tt numtable;
    begin
      select myId bulk collect into tt from some_table;
      update some_other_table set name = 'kakadu' where xId in (select * from tt); -- this line is wrong as it is
    end;What I am doing is fixing a stored procedure that was like this before:
    update table_a set name = 'kakadu' where column_X in (select one.A from table_1 one join table_a on x y z WHERE a b c);
    update table_b set name = 'nimfa'  where column_Y in (select one.B from table_1 one join table_a on x y z WHERE a b c);The problem is, the first UPDATE changes the result of the SELECT, so I want to "remember" it.
    A and B are columns in table_1, A is the primary key. So the fixed code would be like:
    -- store the list of selected IDs from table_1
      select A bulk collect into tt from table_1 one join table_a on x y z WHERE a b c ; -- same conditions as in old code
    -- do the updates
      update table_a set name = 'kakadu' where column_X in (select * from tt);
      update table_b set name = 'nimfa' where column_Y in (select one.B from table_1 one where one.A in tt);(it can be a varray instead of nested table, as far as I am concerned)
    Thanks,
    David

    Yes, it needs to be a SQL type
    Re: How to pass an array to a function from a SELECT statement
    Or you can use a built in SQL type (version dependent)
    Re: Collection in where not working

Maybe you are looking for

  • Document date Issue

    The Document Date is the date when we raise and send a customer Order. Perhaps 2 weeks later we convert this order to an A/R Invoice by using the COPY procedure. However, this procedure changes the Document Date from the original date to the Current

  • How to setup acknowledgements? Please help!

    Hi Experts,    I have following scenario.    IDOC--> XI----> BizTalk    In this scenario, IDOC is sent from SAP R/3 system to XI. XI then sends it to BizTalk using JMS adapter.    Everything works fine and BizTalk also receives the IDOC message. But

  • My AppleTV 2 signal isnt being recognized by my TV

    I have a Philips ambilight and my new AppleTV wont work. I moved it briefly to my sharp TV and the appleTV worked there. I used to have the older model appleTV hooked up to the Philips and it worked just fine. I have tried other components in the HDM

  • Unable to drop materialized view with corrupted data blocks

    Hi, The alert log of our database is giving this message Wed Jan 31 05:23:13 2007 ORACLE Instance mesh (pid = 9) - Error 1578 encountered while recovering transaction (6, 15) on object 13355. Wed Jan 31 05:23:13 2007 Errors in file /u01/app/oracle/ad

  • ITunes 9: program error when closing iTunes9

    Ever since updating to iTunes 9 on my pc running Windows XP SP3 a couple of weeks ago, I get a program error right after having closed iTunes 9. The program error reads: +The instruction at "0x7c90100b" referenced memory at "0x0fc528dc". The memory c