Nested Tables - Oracle Crashes !

Hello Everyone
You might help me to sleep tonight.
Ok, here is the problem.
I used a nested table to collect data. After collection, I get repeated records in collection result. I tried to operate to get a distinct result operating SQL operation but oracle gives nasty error and kicks me out the session.
HERE is the code :
create or replace package rule_engine
as
type t_course_count is table of number(2);
Procedure main;
end rule_engine;
create or replace package body rule_engine
as
procedure main
is
v_course_count t_course_count:=t_course_count(1,2,3,4);
i t_course_count;
begin
insert into table(i) select * from table(v_course_count);
end main;
end rule_engine;
null

Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
  2  /
Type created.
SQL> CREATE TABLE r(
  2    a INTEGER,
  3    b table_type)
  4    NESTED TABLE b STORE as b_1;
Table created.
SQL> CREATE TABLE s(
  2    a INTEGER,
  3    b table_type)
  4    NESTED TABLE b STORE as b_2;
Table created.
SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
1 row created.
SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
1 row created.
SQL> COLUMN c FORMAT A10;
SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
  2  FROM   r, s
  3  WHERE  r.a = s.a;
         A C
         1 TABLE_TYPE('a', 'b', 'c')
SQL>

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.

  • Sql query, from xml to nested table

    Hello!
    I have DB table: my_table
    It has 2 fields: file_id and file_data (it's clob with xml)
    I need to write query that returns info from xml using nested table (Oracle v.9)
    The number of rows witch will return query must be equal to number of files (file_id)
    Structure of XML:
    <?xml version = "1.0" encoding = "utf-8"?>
    <head>
    <AAA v1="a" v2="b">
    <BBB p1="1" p2="2"/>
    <BBB p1="3" p2="4"/>
    </AAA>
    <AAA v1="c" v2="d">
    <BBB p1="5" p2="6"/>
    <BBB p1="7" p2="8"/>
    <BBB p1="9" p2="0"/>
    </AAA>
    </head>
    I have query, witch works! but not optimally! each CLOB scaned 3 times - I want to scan it once!
    SELECT an.file_id,
    CAST(MULTISET(SELECT extract(VALUE(val2),'//@v1').getStringVal() v1,
    extract(VALUE(val2),'//@v2').getStringVal() v2,
    CAST(MULTISET(SELECT extract(VALUE(val3),'//@p1').getStringVal() p1,
    extract(VALUE(val3),'//@p2').getStringVal() p2,
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA/BBB[../@v1='||extract(VALUE(val2),'//@v1').getStringVal()||']'))) val3) AS T_VAL3) info
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA'))) val2) AS T_VAL2) head
    FROM (SELECT olr.*
    FROM my_table olr,
    TABLE (XMLSEQUENCE(XMLTYPE(file_data)).EXTRACT('/head'))) val1) an
    PLEASE, help me to rewrite this query!

    I assume you're using nested objects like these to hold the result?
    create type t_val3_rec as object ( p1 number, p2 number );
    create type t_val3 as table of t_val3_rec;
    create type t_val2_rec as object ( v1 varchar2(30), v2 varchar2(30), c1 t_val3 );
    create type t_val2 as table of t_val2_rec;
    /then this query should work :
    SELECT t.file_id
         , CAST(
             MULTISET(
               SELECT extractvalue(value(x1), '/AAA/@v1')
                    , extractvalue(value(x1), '/AAA/@v2')
                    , CAST(
                        MULTISET(
                          SELECT extractvalue(value(x2), '/BBB/@p1')
                               , extractvalue(value(x2), '/BBB/@p2')
                          FROM TABLE(XMLSequence(extract(value(x1), '/AAA/BBB'))) x2
                        AS t_val3
               FROM TABLE(XMLSequence(extract(value(x), '/head/AAA'))) x1
             AS t_val2
    FROM my_table t
       , TABLE(XMLSequence(extract(xmltype(t.file_data), '/head'))) x
    ;

  • Nested Table Partitioning in 11gR2

    [ Partitioning Concepts for 11gR2|http://download.oracle.com/docs/cd/E11882_01/server.112/e10837/partition.htm] says that Oracle will partition the nested table of a partitioned parent table, automatically:
    "If you partition a table that has a nested table, Oracle Database uses the partitioning scheme of
    the original base table as the basis for how the nested table is partitioned. This partitioning of
    one base table partition for each nested table partition is called equipartitioning. By default,
    nested tables are automatically partitioned when the base table is partitioned."
    Here is some DDL to create a partitioned table with a nested table column:
    CREATE OR REPLACE TYPE ExampElement AS OBJECT (name VARCHAR2(32), val VARCHAR2(4000))
    sho err;
    CREATE OR REPLACE TYPE ExampTableType AS TABLE OF ExampElement
    sho err;
    CREATE TABLE examp (
    uida VARCHAR2(64) NOT NULL,
    idx NUMBER NOT NULL,
    offset SMALLINT DEFAULT -1 NOT NULL ,
    elements ExampTableType,
    CONSTRAINT pk_examp PRIMARY KEY (uida, idx) )
    ORGANIZATION INDEX COMPRESS
    PARTITION BY LIST(uida) (PARTITION IDA_0 values ('xxxxxxxxxxxxxxx') )
    NESTED TABLE elements
    STORE AS elements_tab((constraint pk_elts PRIMARY KEY (nested_table_id, name))
    ORGANIZATION INDEX
    RETURN AS LOCATOR
    sho err;
    I can't find any evidence that Oracle partitioned my nested table. The following do not show any entries corresponding to elements_tab or pk_elts:
    SELECT table_name FROM user_part_tables ;
    SELECT table_name FROM user_part_indexes ;
    My question is, how can I prove to myself that the nested table has been partitioned?
    Thanks,
    Hugh

    The only data dictionary entry that I can find for the elements_tab is in user_nested_tables, but it does not appear that the partitioning is visible to us.
    SCOTT@orcl_11gR2> CREATE OR REPLACE TYPE ExampElement AS OBJECT (name VARCHAR2(32), val VARCHAR2(4000));
      2  /
    Type created.
    SCOTT@orcl_11gR2> CREATE OR REPLACE TYPE ExampTableType AS TABLE OF ExampElement;
      2  /
    Type created.
    SCOTT@orcl_11gR2> CREATE TABLE examp (
      2  uida VARCHAR2(64) NOT NULL,
      3  idx NUMBER NOT NULL,
      4  offset SMALLINT DEFAULT -1 NOT NULL ,
      5  elements ExampTableType,
      6  CONSTRAINT pk_examp PRIMARY KEY (uida, idx) )
      7  ORGANIZATION INDEX COMPRESS
      8  PARTITION BY LIST(uida) (PARTITION IDA_0 values ('xxxxxxxxxxxxxxx') )
      9  NESTED TABLE elements
    10  STORE AS elements_tab((constraint pk_elts PRIMARY KEY (nested_table_id, name))
    11  ORGANIZATION INDEX
    12  )
    13  RETURN AS LOCATOR
    14  /
    Table created.
    SCOTT@orcl_11gR2> SELECT table_name FROM user_part_tables
      2  /
    TABLE_NAME
    EXAMP
    1 row selected.
    SCOTT@orcl_11gR2> SELECT table_name FROM user_part_indexes
      2  /
    TABLE_NAME
    EXAMP
    1 row selected.
    SCOTT@orcl_11gR2> SELECT table_name FROM user_tab_partitions
      2  /
    TABLE_NAME
    EXAMP
    1 row selected.
    SCOTT@orcl_11gR2> SELECT table_name FROM user_nested_tables
      2  /
    TABLE_NAME
    ELEMENTS_TAB
    1 row selected.
    SCOTT@orcl_11gR2>

  • Nested tables and multiset operators in Oracle 10g

    Consider the following scenario:
    We have two identical relations R and S defined as:
    CREATE TABLE R(
    a INTEGER,
    b table_type)
    NESTED TABLE b STORE as b_1;
    CREATE TABLE S(
    a INTEGER,
    b table_type)
    NESTED TABLE b STORE as b_2;
    where table_typ is defined as
    CREATE TYPE table_typ AS TABLE OF VARCHAR2(8);
    Suppose we have two instances of R and S, each having one tuple as follows: R(1,table_typ('a','b')) and S(1,table_typ('b','c')).
    I would like to "merge" these two simple instances (e.g., achieve the effect of a simple SELECT * FROM R UNION SELECT * FROM S query) and obtain the following resulting instance: Result(1,table_typ('a','b','c')).
    Would this be possible in Oracle 10g? A simple UNION does not work (I got a "inconsistent datatypes: expected - got SCOTT.TABLE_TYP" error). I also took a look at the MULTISET UNION operator over nested tables available in Oracle 10g, but it doesn't seem to get me anywhere. Any help on this would be greatly appreciated.
    Thank you,
    Laura

    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE OR REPLACE TYPE table_type AS TABLE OF VARCHAR2 (8);
      2  /
    Type created.
    SQL> CREATE TABLE r(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_1;
    Table created.
    SQL> CREATE TABLE s(
      2    a INTEGER,
      3    b table_type)
      4    NESTED TABLE b STORE as b_2;
    Table created.
    SQL> INSERT INTO r VALUES (1, table_type ('a', 'b'));
    1 row created.
    SQL> INSERT INTO s VALUES (1, table_type ('b', 'c'));
    1 row created.
    SQL> COLUMN c FORMAT A10;
    SQL> SELECT r.a, r.b MULTISET UNION DISTINCT s.b c
      2  FROM   r, s
      3  WHERE  r.a = s.a;
             A C
             1 TABLE_TYPE('a', 'b', 'c')
    SQL>

  • Unable to retrieve data from a nested table in Oracle 8i from JSP

    How do i retrieve data from a nested table in Oracle 8i from my JSP code?
    When i try to execute the query , a general error is thrown.
    Kindly advice as soon as possible.

    How do i retrieve data from a nested table in Oracle 8i from my JSP code?
    When i try to execute the query , a general error is thrown.
    Kindly advice as soon as possible.

  • MERGE using nested table doesn't work on Oracle 9i

    Hi,
    Oracle 9i Enterprise Edition Release 9.2.0.4.0 on Red hat Linux
    SQL> create table PERSONS (
      2    ID  number(9)
      3   ,SURNAME  varchar2(50)
      4   ,constraint PERSONS_PK primary key (ID)
      5  );
    Table created.
    SQL> create or replace type T_NUMBER_ARRAY as table of number;
      2  /
    Type created.
    SQL> create or replace procedure P_MRGTS2 (P_ID  PERSONS.ID%type)
      2  is
      3    L_IDS  T_NUMBER_ARRAY;
      4  begin
      5    L_IDS := T_NUMBER_ARRAY(P_ID);
      6    merge into PERSONS P using (select * from table(L_IDS)) D on (
      7      P.ID = D.COLUMN_VALUE
      8    )
      9    when matched then update
    10      set SURNAME = 'Updated'
    11    when not matched then
    12      insert (
    13        ID
    14       ,SURNAME
    15      )
    16      values (
    17        D.COLUMN_VALUE
    18       ,'Inserted'
    19      );
    20  end;
    21  /
    Procedure created.
    SQL> exec P_MRGTS2(1)
    BEGIN P_MRGTS2(1,'Avi'); END;
    ERROR at line 1:
    ORA-22905: cannot access rows from a non-nested table item
    ORA-06512: at "OPS$AABRAMI.P_MRGTS2", line 9
    ORA-06512: at line 1However, the same code on Oracle 10g Release 10.2.0.1.0 on SUN Solaris 9 works.
    Is there any way to make it work on Oracle 9i?
    One way I found is the following:
    procedure P_MRGTST (P_ID  PERSONS.ID%type)
    is
      L_IDS  T_NUMBER_ARRAY;
    begin
      L_IDS := T_NUMBER_ARRAY(P_ID);
      forall I in L_IDS.first..L_IDS.last
        merge into PERSONS P using DUAL D on (
          P.ID = L_IDS(I)
        when matched then update
          set SURNAME = 'Updated'
        when not matched then
          insert (
            ID
           ,SURNAME
          values (
            L_IDS(I)
           ,'Inserted'
    end;On Oracle 10g there is negligible difference in time taken to execute both procedures, as displayed in SQL*Plus when issuing:
    set timing onIs there something that makes one of the procedures preferrable over the other?
    Thanks,
    Avi.

    Is there any way to make it work on Oracle 9i?
    michaels>  select * from v$version
    BANNER                                                         
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production                          
    CORE     9.2.0.8.0     Production                                      
    TNS for HPUX: Version 9.2.0.8.0 - Production                   
    NLSRTL Version 9.2.0.8.0 - Production                          
    michaels>  create table persons (
        id  number(9)
           ,surname  varchar2(50)
              ,constraint persons_pk primary key (id)    )
    Table created.
    michaels>  create or replace type t_number_array as table of number;
    Type created.
    michaels>  create or replace procedure p_mrgts2 (p_id persons.id%type)
    is
       l_ids   t_number_array;
    begin
       l_ids := t_number_array (p_id);
       merge into persons p
          using (select * from table (cast (l_ids as t_number_array))) d
          on (p.id = d.column_value)
          when matched then
             update set surname = 'Updated'
          when not matched then
             insert (id, surname) values (d.column_value, 'Inserted');
    end p_mrgts2;
    Procedure created.
    michaels>  exec p_mrgts2(1)
    PL/SQL procedure successfully completed.
    michaels>  select * from persons
            ID SURNAME                                          
             1 Inserted                                         
    1 row selected.

  • About nested tables in oracle 8i

    hello,
    actually i am working with oracle 8.1.5 's nested tables
    concept...
    here is a description of my tables
    create type parameterranges
    parameter_name varchar2(20),
    min_value number(10),
    max_value number(10)
    create type parameter_ran as table of parameterranges
    create table material_details
    mat_type varchar2(20),
    parameter_ranges parameter_ran
    okay...
    now my doubt is how do i place constraints on the nested table fields i.e on min_value etc...(especially NOT NULL
    constraint)
    DOUBT NO 2
    =============
    I have a query to find out the mat_type,partno from material_details table Based on the parameter value and its min_value ,i.e based on some name value pairs which I am achieving as below .
    select m.mat_type,m.partno
    from material_details m,table(m.parameter_ranges) p
    where p.parameter ='THICKNESS' and p.min_value = '1'
    and m.mat_type='STEEL'
    intersect
    select m.mat_type, m.partno
    from material_details m,table(m.parameter_ranges) p
    where p.parameter ='STANDARD' and p.min_value = 'SAE1010'
    and m.mat_type='STEEL';
    Now I want this to be in a cursor..i.e I want to use the same set of rows returned by the above in another query involving another table .
    That is using the multiple mat_type and partno returned from above I want to find out
    Other fields (company,plant) from another table part_details which also has a nested table in it
    How do I go about this???Actually I want to use these in a PLSQL procedure where we can have row by row control of the rows returned ,that is why I want a cursor.......
    could u think about this too...and if possible mail me at my yahoo id ..
    thanx once again
    please reply to my id
    [email protected]
    thanx
    null

    I don't understand exactly your problem. Can you send me a mail which expresses your problem??

  • Oracle object, nested table on a subtype

    Hello,
    Is it possible to have a nested table on a subtype? If it is, can someone help me?
    Here is what I need help for:
    I have a supertype WORK, that have:
    multivalued attribute ADDRESS
    a attribute NAME, also the primary key
    The subtype is called EMPLOYEE, that have:
    multivalued attribute SPECIALTY
    a attribute NAME
    a attribute SSN
    So far have I got:
    //* The supertype *//
    create or replace type ADRESS_TP as object(
    ADRESS varchar2(50));
    create or replace type ADRESSTP as table of ADRESS_TP;
    create or replace WORK_TP as object(
    NAME varchar2(30),
    ADRESS ADRESSTP)
    NOT FINAL;
    create table WORK_TBL of WORK_TP(
    Primary key(NAME))
    nested table ADRESS store as NT_ADR(
    (Primary key(nested_table_id, ADRESS))
    organization index compress);
    //* The subtype *//
    create or replace type SPECIALTY_TP as object(
    ADRESS varchar2(50));
    create or replace type SPECIALTYTP as table of SPECIALTY_TP;
    create or replace EMPLOYEE_TP under work_tp(
    NAME varchar2(30),
    SSN number)
    FINAL;
    The multivalued attribute SPECIALTYTP has to be declared in WORK_TBL have I been told, but how can I do that?
    I'm using oracle 9i

    I'm not really sure what your problem is. In future please be specific about what it is you are trying to do and what it is that is not working. If it's an error please give us the error message and number. It's not the behaviour you are expecting please describe what it does. If it's that you simply don't understand please say what you don't understand.
    I go on like this because the code you have posted is somewhat confusing. The Oracle object-oriented implementation is not quite complete so that makes it hard for people who know OO but don't know Oracle. Whereas most of us who know Oracle aren't expert in OO. Also, I think you should be slightly more inventive in your names: there's so many things called ADRESS it's easy to get them tangled up.
    Anyway, here's my guess at what I think your problem is....
    SQL> CREATE OR REPLACE TYPE adress_t AS OBJECT(
      2  line1 VARCHAR2(50)
      3  ,line2 VARCHAR2(50)
      4  ,postcode VARCHAR2(8));
      5  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE adress_nt AS TABLE OF adress_t;
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE work_t AS OBJECT(
      2   name VARCHAR2(30),
      3   adresses adress_nt)
      4  NOT FINAL;
      5  /
    Type created.
    SQL> CREATE TABLE work_tbl OF work_t
      2     NESTED TABLE adresses STORE AS adress_ntab
      3  /
    Table created.
    SQL> CREATE OR REPLACE TYPE specialty_t AS OBJECT(
      2  description VARCHAR2(50));
      3  /
    Type created.
    SQL> CREATE OR REPLACE TYPE specialty_nt AS TABLE OF specialty_t;
      2  /
    Type created.
    SQL>
    SQL> ALTER TYPE work_t ADD ATTRIBUTE specialities specialty_nt CASCADE
      2  /
    Type altered.
    SQL> DESC work_tbl
    Name                                      Null?    Type
    NAME                                               VARCHAR2(30)
    ADRESSES                                           ADRESS_NT
    SPECIALITIES                                       SPECIALTY_NT
    SQL> Cheers, APC

  • Problems with Whitespace using nested tables from eclipse dtp oracle plugin

    Hi,
    sending from eclipse to oracle xe fails if whitespace is used:
    Example1: Nested table in nested table
    adress_table_typ has another nested table in it
    that works
    CREATE TABLE x (
    i INTEGER PRIMARY KEY,
    adressen adress_table_typ
    ) NESTED TABLE adressen STORE AS adressen_nt (NESTED TABLE tels STORE AS tels_nt);
    inserting a newline fails
    CREATE TABLE x (
    i INTEGER PRIMARY KEY,
    adressen adress_table_typ
    ) NESTED TABLE adressen STORE AS adressen_nt
    (NESTED TABLE tels STORE AS tels_nt);
    Example2:
    Two nested tables
    CREATE TABLE x (
    i INT PRIMARY KEY,
    l_table_typ,
    m_table_typ
    ) NESTED TABLE laptops STORE AS laptop_nt NESTED TABLE interessen STORE AS interessen_nt;
    and then an insert
    INSERT INTO x VALUES (123456,
    l_typ(laptop_typ('123', 'netop'),
    laptop_typ('234', 'thinkpad'),     
    laptop_typ('345', 'iBook')),
    m_typ('a', 'b', 'c')
    which fails. Note that the INSERT works when copy&pasted to sqlplus. It also works if there is
    just one nested table.
    Am I doing somethig wrong or is this a bug in the eclipse data tools plugin?
    Regards
    - Peter
    PS; It is rather difficult to insert whitespace in that forum editor. Any possibility to have ascii?
    For a "whitespace" question rather important...

    A bit of an update on the original post. I was playing around with the plug-in xml file (e.g. eclipse\plugins\org.eclipse.jst.server.generic.oc4j_1.5.100.v20070608\buildfiles\oracle.10.1.3.xml). I changed the following from "deploy" to "redeploy" and it seems to be working once the applicatoin is initial deployed. Of course, I have to change it back to "deploy" if it is the first time the application is being deployed. However; I would still would like to resolve this if there is something out there that fixes this problem. Or if everything points to an enviornment problem, I can continue to play with it.
    <target name="deploy.j2ee.ear" depends="check.skip.ear.deploy" unless="skip.deploy">
    <antcall target="package.module.ear"/>
    <oracle:redeploy
    deployerUri="${deployer.uri}"
    userId="${oc4j.admin.user}"
    password="${oc4j.admin.password}"
    file="${server.publish.dir}/${module.name}.ear"
    deploymentName="${module.name}"
    bindAllWebApps="${oc4j.bind.website}"/>
    </target>

  • Nested Table having more than 1 column comparison using ORACLE MULTISET

    Dear ALL,
    I am using ORACLE 10gR2 Database.
    I am currently trying to compare two sets of data that I get from two queries in PL/SQL. I want to use Oracle MULTISET UNION, MULTISET INTERSECT, MULTISET EXCEP for those operations.
    But When I am executing the below given code I am getting the error.
    PLS-00306: wrong number or types of arguments in call to 'MULTISET_EXCEPT_ALL'
    My Code
    declare
    type wh_unique_record is record (cpy_key number(22),cnc_id varchar2(22),cust_type_id number,
    device_info_id number,scope_id number,excep_id number,
    config_date date);
    type wh_previous_data_table is table of wh_unique_record;
    wh_previous_data wh_previous_data_table;
    wh_current_data wh_previous_data_table;
    wh_union_data wh_previous_data_table;
    wh_intersect_data wh_previous_data_table;
    -- This cursor I am using to populate the data into the nested tables
    cursor c_previous_data is select cpy_key,cnc_id,cust_type_id,device_info_id,scope_id,excep_id,config_date
    from r_cfg_wh_excep
    where cpy_key=17278
    and trunc(config_date)=trunc(to_date('06-jul-2009','dd-mon-yyyy'));
    cursor c_current_data is select cpy_key,cnc_id,cust_type_id,device_info_id,scope_id,excep_id,config_date
    from r_cfg_wh_excep
    where cpy_key=17278
    and trunc(config_date)=trunc(to_date('16-jul-2009','dd-mon-yyyy'));
    begin
    open c_previous_data;
    fetch c_previous_data bulk collect into wh_previous_data;
    close c_previous_data;
    open c_current_data;
    fetch c_current_data bulk collect into wh_current_data;
    close c_current_data;
    dbms_output.put_line('Previous count '||wh_previous_data.count);
    dbms_output.put_line('Current count '||wh_current_data.count);
    --FYI: MULTISET UNION IS WORKING.*
    wh_union_data := wh_current_data multiset union wh_previous_data;
    dbms_output.put_line('New count '||wh_union_data.count);
    wh_intersect_data:=wh_current_data MULTISET EXCEPT  wh_previous_data;
    dbms_output.put_line('The records that are repeating are  '||wh_intersect_data.count);
    end;
    Previous count 74062
    Current count 74508
    New count 148570
    PL/SQL procedure successfully completed.
    FYI: If I comment the MULTISET EXCEPT conditin then I am getting the output for MULTISET UNION.
    IS THERE ANY WAY ORACLE IS PROVIDING A FUNCTIONALITY WHERE WE CAN HAVE A NESTED TABLE WITH MULTIPLE COLUMNS AND THAT CAN BE USED IN PL/SQL AND USE BULK OPERATION TO POPULATE THE NESTED TABLE WITH MULTIPLE COLUMNS AND USE THE SAME IN MULTISET EXCEPT, MULTISET EXCEPT ETC.
    Appreciate your help on this.
    Thanks,
    Madhu K.

    Madhu,
    I am totally amazed. I didn't think any of the MULTISET operations would work with NTs of records. Lucky you!
    As for the EXCEPT, well, clearly it is a restriction or bug in PL/SQL.
    You may want to report it to Oracle Support.
    Regards,SF
    At 11:45 AM 10/1/2009, you wrote:
    Dear Steven,
    I am using ORACLE 10gR2 Database.
    I am currently trying to compare two sets of data that I get from two queries in PL/SQL. I want to use Oracle MULTISET UNION, MULTISET INTERSECT, MULTISET EXCEP for those operations.
    But When I am executing the below given code I am getting the error.
    PLS-00306: wrong number or types of arguments in call to 'MULTISET_EXCEPT_ALL'
    My Code
    declare
    type wh_unique_record is record (cpy_key number(22),cnc_id varchar2(22),cust_type_id number,
    device_info_id number,scope_id number,excep_id number,
    config_date date);
    type wh_previous_data_table is table of wh_unique_record;
    wh_previous_data wh_previous_data_table;
    wh_current_data wh_previous_data_table;
    wh_union_data wh_previous_data_table;
    wh_intersect_data wh_previous_data_table;
    -- This cursor I am using to populate the data into the nested tables
    cursor c_previous_data is select cpy_key,cnc_id,cust_type_id,device_info_id,scope_id,excep_id,config_date
    from r_cfg_wh_excep
    where cpy_key=17278
    and trunc(config_date)=trunc(to_date('06-jul-2009','dd-mon-yyyy'));
    cursor c_current_data is select cpy_key,cnc_id,cust_type_id,device_info_id,scope_id,excep_id,config_date
    from r_cfg_wh_excep
    where cpy_key=17278
    and trunc(config_date)=trunc(to_date('16-jul-2009','dd-mon-yyyy'));
    begin
    open c_previous_data;
    fetch c_previous_data bulk collect into wh_previous_data;
    close c_previous_data;
    open c_current_data;
    fetch c_current_data bulk collect into wh_current_data;
    close c_current_data;
    dbms_output.put_line('Previous count '||wh_previous_data.count);
    dbms_output.put_line('Current count '||wh_current_data.count);
    --FYI: MULTISET UNION IS WORKING.
    wh_union_data := wh_current_data multiset union wh_previous_data;
    dbms_output.put_line('New count '||wh_union_data.count);
    wh_intersect_data:=wh_current_data MULTISET EXCEPT wh_previous_data;
    dbms_output.put_line('The records that are repeating are '||wh_intersect_data.count);
    end;
    Previous count 74062
    Current count 74508
    New count 148570
    PL/SQL procedure successfully completed.
    FYI: If I comment the MULTISET EXCEPT conditin then I am getting the output for MULTISET UNION.
    IS THERE ANY WAY ORACLE IS PROVIDING A FUNCTIONALITY WHERE WE CAN HAVE A NESTED TABLE WITH MULTIPLE COLUMNS AND THAT CAN BE USED IN PL/SQL AND USE BULK OPERATION TO POPULATE THE NESTED TABLE WITH MULTIPLE COLUMNS AND USE THE SAME IN MULTISET EXCEPT, MULTISET EXCEPT ETC.
    Appreciate your help on this.
    Thanks,
    Madhu K.

  • Oracle error ORA-22905: cannot access rows from a non-nested table item

    Oracle error ORA-22905: cannot access rows from a non-nested table item
    Creating a report using oracle plsql code .
    Getting error ;
    Oracle error ORA-22905: cannot access rows from a non-nested table item
    when I am trying to pass data in clause in pl sql proc
    basically I have a proc which takes 2 parameters(a and b)
    proc (
    P_a varchar2,
    p_b varchar2,
    OUT SYS_REFCURSOR
    culprit code which is giving me  the error and on google they say cast it but I dont know how to do it in my context
    --where  id in (
    --        SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_a) FROM dual)
    --        union
    --        SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_b) FROM dual)
    data sample returned from this :SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_a) FROM dual)
    'Abc','def',
    data sample returned from this;SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_b) FROM dual)
    'fgd','fth',
    Any answers ?
    How to pass data in clause in a better way

    Why are you creating a duplicate post? I already asked you to post p_cd_common.get_table_from_string. In particular what is function return type and where it is declared. As I already mentioned, most likely function return type is declared in the package and therefore is PL/SQL type. And TABLE operator can only work with SQL types.
    SY.

  • Expoting/Importing Oracle BLOB, CLOB, Nested Tables datatypes

    I am trying to export the database containing BLOB, Nested Tables etc. and wants to import the same. But i am getting an error. Pleease help as to how i will proceed with it. This is something very urgent. please reply . i will be very thankful to you

    I believe this error is only associated with LONG data type. I have been using data pump to export/import table with LOB type without any problem.
    Data pump been having issue with LONG type check this bug
    Bug 5598333 - EXPDP/IMPDP corrupts the data for a LONG column
    Doc ID: Note:5598333.8
    It's fixed in 11.1.0.6

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

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

Maybe you are looking for

  • New Time Zone Issue with MobileMe Calendar Upgrade

    I'm having strange things happen with sending/receiving "invitations" to people in other time zones. Prior to this MobileMe calendar upgrade, sending/receiving invitations worked fine. I would schedule an event (obviously in my time zone), and if I i

  • Most efficient way to constantly read, queue and parse multi-size​d RS232 data (multi-thr​eaded)

    I've tried tackling this problem a few different ways, and figured it was time to get some others' advice.  My system essentially works, although it looks like a hackjob and not entirely confident. My RS-232 connection has the following properties/co

  • Removing New button fields from WEB UI

    Hi, We are working on IC-AGENT Business role in that Account id we dont to assinge New creation button to User. PFCG role we are restricting . Its working but NEW button is still appiearing . We dont want this new button in enable mode . it should be

  • Proxy Server 3.6 StdIn Error

    I have seen a similiar post previously, but not a response. Several errors with the Sun/1 Proxy Server 3.6 sp 1 proxy on Solaris 8 with reverse-proxy URL's configured: 1. Attempting to turn on access control from the Restrict Access page on Server pr

  • Freehand MX crashes when trying to open Freehand 10 files

    Hello, I hope someone out there has some suggestions. I need to open some Freehand 10 documents in Freehand MX. When I try to open the FH10 files in Freehand MX it crashes. The icon it self looks like a blank page as if MX doesn't recognize it. I rei