IN operator in nested tables

Hi,
Does anyone can redo an IN operator in nested tables example?
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjcol.htm#sthref396
My example returns no row...
CREATE TYPE Pilote_elt_nt_type AS OBJECT
(brevet VARCHAR(4), nomPil VARCHAR(15),
MAP MEMBER FUNCTION get_brevet RETURN VARCHAR)
CREATE TYPE BODY Pilote_elt_nt_type AS
MAP MEMBER FUNCTION get_brevet RETURN VARCHAR IS
BEGIN
RETURN brevet;
END get_brevet ;
END;
CREATE TYPE Pilotes_nt_type AS TABLE OF Pilote_elt_nt_type
CREATE TABLE Compagnie
(numComp VARCHAR2(2) PRIMARY KEY,
nomComp VARCHAR2(20),
commandants_nt Pilotes_nt_type,
instructeurs_nt Pilotes_nt_type,
pilotes_nt Pilotes_nt_type)
NESTED TABLE commandants_nt STORE AS commandants_tabnt
NESTED TABLE instructeurs_nt STORE AS instructeurs_tabnt
NESTED TABLE pilotes_nt STORE AS pilotes_tabnt;
INSERT INTO Compagnie
VALUES ('C1','Air France',
Pilotes_nt_type (
          Pilote_elt_nt_type ('PL-1','C. Sigaudes'),
Pilote_elt_nt_type ('PL-3','A. Bidal'),
Pilote_elt_nt_type ('PL-2','S. Payrissat')
Pilotes_nt_type (
          Pilote_elt_nt_type ('PL-2','S. Payrissat')
Pilotes_nt_type (          
Pilote_elt_nt_type ('PL-3','A. Bidal'),
Pilote_elt_nt_type ('PL-1','C. Sigaudes'),
          Pilote_elt_nt_type ('PL-4','F. Périssel')) );
SELECT p.nomPil
FROM Compagnie, TABLE(commandants_nt) p;
SELECT p.nomPil
FROM Compagnie, TABLE(instructeurs_nt) p;
SELECT p.nomPil
FROM Compagnie, TABLE(pilotes_nt ) p;
--no row !
SELECT p.nomPil
FROM Compagnie, TABLE(commandants_nt) p
WHERE commandants_nt IN (pilotes_nt,instructeurs_nt);

Actually, my general advices are not my original advices, but (mostly) C.J.Date's advices.
I'm IT practitioner (not IT scientists), but I highly appreciate work (theoretical and practical) of IT scientists like
Edsger W.Dijkstra, C.Antony.R Hoare, John W.Backus, Peter Naur, Ole-Johan Dahl, Kristen Nygaard, Donald E.Knuth,
Niklaus E.Wirth, Alan C.Kay, Edgar F.Codd, Christopher J.Date, Bertrand Meyer ... and many more.
I like OOPL's, especially Eiffel. But mostly I like relational model and relational DBMS's.
My motto is: “Thou shall not do in the Middle Tier, what thou could have done in the Data Tier”
(Toon Koppelaars in "A first JDeveloper project: Choices made, lessons learned", Oracle World 2002).
First, I don't like to use REF's in Oracle (relational) DBMS.
C.J.Date in "An introduction to Database Systems" (eighth edition, 2004, chapter 26) says:
- "The Second Great Blunder consists of mixing pointers [REF's] and relations"
- "The Second Great Blunder undermines the conceptual integrity of the relational model in numerous ways"
Second, using nested tables in relational database is "legal". In the same book (page 373) Date says:
"... it is possible for a relation to include an attribute whose values are relations in turn...
Historically, in fact, such relvars [relation variables] were not even legal -
they were said to be unnormalized, meaning they were not even regarded as being in 1NF".
But, note that on the same page Date says:
"From the point of view of database design, however, such relvars are usually contraindicated,
because they tend to be asymmetric ... and such asymmetry can lead to various practical problems".
So, we can use nested tables (relational-valued attributes), but very very sparingly, and I agree with Billy (Verreynne):
I also think this design of yours (using nested tables instead of normal relational tables) it a very much flawed approach. Third, I use object types as domains. In the same book (page 885) Date says:
"... object/relational systems ... are, or should be, basically just relational systems that support the relational domain concept (i.e., types) properly
- in other words, true relational systems, meaning in particular systems that allow users to define their own types".
Here is my attempt to use Oracle "object-relational" features "in the proper way" (in Date's sense) - to use object type as domain:
“OR(DBMS) or R(DBMS), That is the Question”
http://www.quest-pipelines.com/pipelines/plsql/tips.htm#OCTOBER
Date says that "The First Great Blunder" is to equate object classes and relational variables,
simply speaking - to have object tables (tables in which each row represents an object).
I must say that I'm not 100% sure about "The First Great Blunder" in Oracle (see Re: to REF or not to REF? or Re: difference between value and deref clause in oop).
Date says that one consequence of "The First Great Blunder" is to have subtables and supertables.
Subtables and supertables exists in SQL:1999 standard. But, in Oracle we can't say (SQL:1999 syntax):
CREATE TABLE programmer_obj_tab OF programmer_type UNDER emp_obj_tab;
Oracle hasn't (explicit) subtables and supertables.
I recommend to you Billy's threads - you can find many excellent advices and opinions.
Regards,
Zlatko

Similar Messages

  • Getting Compilation error when used SET or MULTISET operator on nested tabl

    Dear All,
    I am getting Compilation error when used SET or MULTISET operator on nested tables inside a procedure.
    This is working fine in other DB installations of 10g but does not work in another 10g DB.
    it says "wrong number of parameter or datatype used in SET"
    Can any one suggest what went wrong here?
    Thanks in advance.

    Can any one suggest what went wrong here?Only if you would post the query and Oracle versions on both databases.
    Besides, this forum deals with issues in Oracle product installation. So post this query in SQL PL/SQL forum for better response.

  • Compilation error when used SET or MULTISET operator on nested tables

    Dear All,
    I am getting Compilation error when used SET or MULTISET operator on nested tables inside a procedure.
    This is working fine in other DB installations of 10g but does not work in another 10g DB.
    it says "wrong number of parameter or datatype used in SET"
    Can any one suggest what went wrong here?
    Thanks in advance.

    Hi,
    Thanks for ur reply...
    Since MULTISET and SET operators are the new additions in base 10g release for manipulation of nested tables data, I am surprised that same is working in similar 5 DBs installations with 10.2.0.1.0 version, but does not work in the sixth.
    SET and MULTISET operators are used inside the PL/SQL procedure which is getting compiled in the above mentioned 5 DBs but not in sixth DB.
    it gives
    On line: 3112
    PLS-00306: wrong number or types of arguments in call to 'SET'
    Hope this clarifies the issue...

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

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

  • Why can't  I import a nested table?

    My Operation system is Win NT 4.0 (Package 6)
    data base is oracle 8.1.6
    now, I craete a table TAB01 nested table TAB02NT.
    All operation such as delete ,insertion goes no well.
    I have export the table TAB01 without any warings and errors
    But a error occured when I import the exported table TAB01
    the error below :
    IMP-00017
    IMP-00003
    ORA-02304
    IMP-00063
    why ?

    Yanxiang,
    If you have a customer ID, you can go to
    http://metalink.oracle.com to file an iTAR with test case to
    reproduce your error.
    Regards,
    Geoff
    My Operation system is Win NT 4.0 (Package 6)
    data base is oracle 8.1.6
    now, I craete a table TAB01 nested table TAB02NT.
    All operation such as delete ,insertion goes no well.
    I have export the table TAB01 without any warings and errors
    But a error occured when I import the exported table TAB01
    the error below :
    IMP-00017
    IMP-00003
    ORA-02304
    IMP-00063
    why ?

  • Import tables with nested table : ORA-00600

    In Oracle 9.2
    Create object, type as table, and table with nested table (store as syms_ntab) are successfully.
    Also its export.
    In process of import on another server (also 9.2, 'fromuser=one touser=two') shows errors:
    . . importing table "SYMS_NTAB"
    IMP-00058: ORACLE error 600 encountered
    ORA-00600: internal error code, arguments: [kokeeafi1], [2], [2], [], [], [], [], []
    IMP-00075: Warning: The nested table may contain partial rows or duplicate rows
    But for all that table is created and error occur on phase inserting strings.
    What is this?
    In Oracle 8.0.5 i perform similar operation without error.

    From Oracle error messages and codes manual:
    ORA-00600 internal error code, arguments: [string], [string], [string], [string], [string], [string], [string], [string]
    Cause: This is the generic internal error number for Oracle program exceptions. It indicates that a process has encountered a low-level, unexpected condition. Causes of this message include:
    * timeouts
    * file corruption
    * failed data checks in memory
    * hardware, memory, or I/O errors
    * incorrectly restored files
    The first argument is the internal message number. Other arguments are various numbers, names, and character strings. The numbers may change meanings between different versions of Oracle.
    Action: Report this error to Oracle Support Services after gathering the following information:
    * events that led up to the error
    * the operations that were attempted that led to the error
    * the conditions of the operating system and databases at the time of the error
    * any unusual circumstances that occurred before receiving the ORA-00600 message
    * contents of any trace files generated by the error
    * the relevant portions of the Alter files
    Note: The cause of this message may manifest itself as different errors at different times. Be aware of the history of errors that occurred before this internal error.

  • Problem in truncate/drop partitions in a table having nested table columns.

    Hi,
    I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it help?
    Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
    Thanks in advance.

    >
    I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table?
    >
    Unfortunately you can't do those operations when a table has a nested table column. No truncate, no drop, no exchange partition at the partition level.
    A nested table column is stored as a separate table and acts like a 'child' table with foreign keys to the 'parent' table. It is these 'foreign keys' that prevent the truncation (just like normal foreign keys prevent truncating partions and must be disabled first) but there is no mechanism to 'disable' them.
    Just one excellent example (there are many others) of why you should NOT use object columns at all.
    >
    IF I change column types from nested table to varray type, will it help?
    >
    Yes but I STRONGLY suggest you take this opportunity to change your data model to a standard relational one and put the 'child' (nested table) data into its own table with a foreign key to the parent. You can create a view on the two tables that can make data appear as if you have a nested table type if you want.
    Assuming that you are going to ignore the above advice just create a new VARRAY type and a table with that type as a column. Remember VARRAYs are defined with a maximum size. So the number of nested table records needs to be within the capacity of the VARRAY type for the data to fit.
    >
    Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
    >
    Sure - just CAST the nested table to the VARRAY type. Here is code for a VARRAY type and a new table that shows how to do it.
    -- new array type
    CREATE OR REPLACE TYPE ARRAY_T AS VARRAY(10) OF VARCHAR2(64)
    -- new table using new array type - NOTE there is no nested table storage clause - arrays stored inline
    CREATE TABLE partitioned_table_array
         ( ID_ INT,
          arra_col  ARRAY_T )
         PARTITION BY RANGE (ID_)
         ( PARTITION p1 VALUES LESS THAN (40)
         , PARTITION p2 VALUES LESS THAN(80)
         , PARTITION p3 VALUES LESS THAN(100)
    -- insert the data from the original table converting the nested table data to the varray type
    INSERT INTO PARTITIONED_TABLE_ARRAY
    SELECT ID_, CAST(NESTED_COL AS ARRAY_T) FROM PARTITIONED_TABLENaturally since there is no more nested table storage you can truncate or drop partitions in the above table
    alter table partitioned_table_array truncate partition p1
    alter table partitioned_table_array drop partition p1

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

  • Bind ordered pair of nested tables into cursor

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

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

  • Varray, Nested Table and Object types in OWB r2

    Requirement:
    Flat file with repeating groups of nested content need to move into Object Relational ORACLE table (using varray or nested tables - no preference). The data will be loaded, then mapped/transformed into a richer O-R output to directly produce XML outputs.
    Problem:
    Generated PL/SQL "seems" to do the correct thing, but deployment errors show failures on mapping of collections (varrays, NTs or OTs) and in sqlplus recompiling the PKB still gives the errors. Is this a PL/SQL generator error, or is there a more meaningful example of using CONSTRUCT OBJECT operator than the embedded odcumentation - it is a simple type (single instance) and not a variable repeating group of nested data.
    Anyone had any success with these, or know of any collateral to assist in the process. Thanks.

    The process we are following is very simple. We are talking 10 columns from a source flat file table and wish to map this into a Varray/Nested table, with one column of Varchar2(10).
    When you create your map in OWB, select the construct object, you have to choose an object type - it does not allow you to select a VARAAY or NESTED table.
    I have then created an object defined in the same structure as the VARRAY/NESTED table - I have then made the VARRAY/NESTED table of this TYPE.
    Example:
    CREATE OR REPLACE TYPE "O_REL_PUB_INDEX" AS OBJECT (
    X_REL_PUB_INDEX_1 VARCHAR2(10))
    CREATE OR REPLACE TYPE "V_REL_PUB_INDEX" AS VARRAY(15) OF O_REL_PUB_INDEX
    In OWB you can then select O_REL_PUB_INDEX when creating the 'Contruct Object'.
    The problem I have is that when I map to my target column of type V_REL_PUB_INDEX and DEPLOY my map I get the following errors taken from OWB control centre
    Name
    Action
    Status
    Log
    TEST
    Create
    Warning
    ORA-06550: line 2931, column 9:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 3174, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    TEST
    Create
    Warning
    ORA-06550: line 401, column 7:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 643, column 13:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    TEST
    Create
    Warning
    ORA-06550: line 7221, column 9:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 7464, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    Any ideas? anyone succesfully mapped to either a VARRAY or an NESTED TABLE target column?

  • DML on nested tables using SQL

    Hello. Can anyone tell me what's wrong??
    SQL> create type mytype as table of varchar2(20);
    Type created
    real: 78
    SQL> declare
    2 c mytype;
    3 begin
    4 select table_name bulk collect into c from user_tables;
    5 delete from table(cast(c as mytype));
    6 end;
    7 /
    declare
    ERROR at line 1:
    ORA-06550: line 5, column 13:
    PL/SQL: ORA-00903: invalid table name
    ORA-06550: line 5, column 1:
    PL/SQL: SQL Statement ignored
    real: 31

    we cannot use variables in regular SQL. It has to be
    dynamic, viz
    begin
    for r in ( select table_name from user_tables )
    loop
    execute immediate ' delete from '||r.table_name;
    d loop;
    end;
    /Cheers, APCyes, but user_tables was only a example. I want to load some data into nested table using BULK COLLECT and then perform some operation on this pl/sql table.
    For example:
    SELECT col BULK COLLECT INTO c FROM a_table;
    SELECT * BULK COLLECT INTO d FROM TABLE(CAST (c AS sql_type));
    --After that c and d contain the same data
    --but for example
    UPDATE TABLE(CAST(c AS sql_type)) Set c.col=...;
    generates invalid table name.
    Why SELECT INTO works, and UPDATE doesn't (all of this was in PL/SQL context, not SQL).

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

  • Severe Pro*C / nested table error

    I am experiencing a nasty error which involves Pro*C accessing nested table columns. I am running Oracle 9.2.0.1.0 on Solaris 2.8 and using the GNU gcc compiler.
    In my examples, I will use the sample data which comes with Pro*C ($ORACLE_HOME/precomp/demo/sql/coldemo1.sql).
    This defines the following types and table (and also populates the table with sample data):
    CREATE TYPE city_t AS OBJECT (name CHAR(30), population NUMBER);
    CREATE TYPE citytbl_t AS TABLE OF city_t;
    CREATE TABLE county_tbl (name CHAR(30), cities citytbl_t)
    NESTED TABLE cities STORE AS citytbl_t_tbl;
    I have no problems running the sample program ($ORACLE_HOME/precomp/demo/proc/coldemo1.pc). Note that you must follow the instructions included in the comments of coldemo1.pc (manually execute the Oracle Type Translator, precompile, compile and link).
    The sample, however, merely retrieves and displays existing data. I would like my program to be able to insert new rows into county_tbl, including the nested table.
    I have the following code (for simplicitys sake, everything is in the main procedure):
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sqlca.h>                                /* SQL Communications Area */
    #include <coldemo1.h>        /* OTT-generated header with C typedefs for the */
                                          /* database types city_t and citytbl_t */
    #define CITY_NAME_LEN    30
    #define COUNTY_NAME_LEN  30
    #define MAXCITIES 5
    void PrintSQLError()
      EXEC SQL WHENEVER SQLERROR CONTINUE;
      printf("SQL error occurred...\n");
      printf("%.*s\n", (int)sqlca.sqlerrm.sqlerrml,
             (CONST char *)sqlca.sqlerrm.sqlerrmc);
      EXEC SQL ROLLBACK RELEASE;
      exit(-1);
    int main(int argc, char *argv[])
      char * uid = "scott/tiger";
      citytbl_t *cityTable;
      OCIInd cityTableInd;
      char county[COUNTY_NAME_LEN + 1];
      city_t *city[MAXCITIES];
      city_t_ind *cityInd[MAXCITIES];
      char cname[CITY_NAME_LEN + 1];
      int cpop;
      int numCities = MAXCITIES;
      int i, tableSize;
      EXEC SQL WHENEVER SQLERROR DO PrintSQLError();
      EXEC SQL CONNECT :uid;
      /* to null-terminate strings */
      EXEC ORACLE OPTION (char_map=string);
      /* Allocate the required descriptors */
      EXEC SQL ALLOCATE :cityTable;
      EXEC SQL ALLOCATE :city:cityInd;
      strcpy(county,"MYCOUNTY");
      /* Create an array of city objects */
      EXEC SQL FOR :numCities OBJECT CREATE :city:cityInd;
      for(i=0;i<numCities;i++)
        sprintf(cname,"city%d", i);
        cpop = (i * 100);
        EXEC SQL OBJECT SET NAME, POPULATION OF :city[i] TO :cname, :cpop;
        cityInd[i]->_atomic = cityInd[i]->NAME = cityInd[i]->POPULATION = OCI_IND_NOTNULL;
      cityTableInd = OCI_IND_NOTNULL;
      EXEC SQL COLLECTION APPEND :city:cityInd TO :cityTable:cityTableInd;
      EXEC SQL INSERT INTO county_tbl (NAME, CITIES) VALUES (:county, :cityTable:cityTableInd);
      EXEC SQL FREE :city;
      EXEC SQL FREE :cityTable;
      EXEC SQL COMMIT RELEASE;
      return(0);
    }This works as expected, inserting one row into COUNTY_TBL, with name=MYCOUNTY, cities being a nested table containing five city elements.
    My problem occurs when I create a trigger on COUNTY_TBL which attempts to modify elements of the nested table column. Heres the trigger (in this case, we are converting each NAME element of the cities table to upper case):
    create or replace trigger biur_county
    before insert or update on county_tbl
    for each row
    when (new.cities is not null)
    BEGIN
    IF(:NEW.cities.COUNT > 0) THEN
    FOR i IN :NEW.cities.FIRST..:NEW.cities.LAST LOOP
    :NEW.cities(i).NAME := UPPER( :NEW.cities(i).NAME );
    END LOOP;
    END IF;
    END biur_county;
    From SQL*Plus, this works as expected:
    SQL> insert into county_tbl values ('ANOTHERCOUNTY',CITYTBL_T(CITY_T('city1',1),CITY_T('city2',2)));
    1 row created.
    SQL> select * from county_tbl where name='ANOTHERCOUNTY';
    NAME
    CITIES(NAME, POPULATION)
    ANOTHERCOUNTY
    CITYTBL_T(CITY_T('CITY1 ', 1), CITY_T('CITY2 ', 2))
    1 row selected.
    Note that the city names have been converted to upper case.
    If, however, I attempt to run the Pro*C program again, with the trigger enabled, I get a severe error:
    ORA-03113: end-of-file on communication channel
    This also creates entries in the alert log:
    Errors in file /space/oracle/product/9.2.0.1.0/admin/ATDEV/udump/atdev_ora_16790.trc:
    ORA-07445: exception encountered: core dump [0000000100C8EF7C] [SIGBUS] [Invalid address alignment] [0x400000006] [] []
    The trace file includes:
    Exception signal: 10 (SIGBUS), code: 1 (Invalid address alignment), addr: 0x400000006, PC: [0x100c8e
    f7c, 0000000100C8EF7C]
    *** 2002-12-11 15:51:25.469
    ksedmp: internal or fatal error
    ORA-07445: exception encountered: core dump [0000000100C8EF7C] [SIGBUS] [Invalid address alignment]
    [0x400000006] [] []
    Current SQL statement for this session:
    insert into county_tbl (NAME,CITIES) values (:b0,:b1:b2)
    ----- PL/SQL Call Stack -----
    object line object
    handle number name
    38421f020 3 SCOTT.BIUR_COUNTY
    If I subsequently disable the trigger (or alter the trigger so that the contents of the nested table are not modified), all is well again.
    Has anyone else encountered a similar problem? I am assuming that the problem has something to do with the objects in Pro*C being transient and held in the object cache on the client. Perhaps I am doing something wrong in my program. Does anyone have any thoughts?
    Certainly there are ways around this problem (remove the trigger, for example, or perform inserts through a view / instead of trigger, etc), but I would like to have an explanation as to why my method is not working.
    Any insights would be greatly appreciated.

    HELLO!!!
    This problem reveals ONLY in DEBUG configuration (in RELEASE - all ok, but DEBUG is very important feature ;)) and operator
    new in my case have not an influence on this situation.
    I found a problem in other place when calling boxes=box.ptr();
    The boxes oracle class have a nested table. In C++ :
    class CBoxes : public oracle::occi::PObject {
    private:
    OCCI_STD_NAMESPACE::string BOXNAME;
    oracle::occi::Number BOXNUM;
    OCCI_STD_NAMESPACE::vector<CWidget*> WIDGETS;
    ptr() function calling readSQL method of CBoxes class:
    BOXNAME = streamOCCI_.getString();
    BOXNUM = streamOCCI_.getNumber();
    oracle::occi::getVector(streamOCCI_, WIDGETS);
    and getVector is:
    //cutted from occiObjects.h------------------------------
    template <class T>
    void getVector(const AnyData &any, OCCI_STD_NAMESPACE::vector<T> &vect)
    {OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;      
    getVectorOfPObjects( any,vec_pobj);//!!!!!!! :[  ]
    vect.clear();
    int size= vec_pobj.size();
    for( int i=0; i< size; i++)
    vect.push_back( (T)vec_pobj[i] );
    }//<- the destructor of vec_pobj is being called and if vec_pobj not an empty vector, the program crashes.
    I suppose that getVectorOfPObjects( any,vec_pobj) can't correctly allocate memory for vec_pobj elements in DEBUG mode.

  • Simple question aboout PL/SQL nested tables

    Hello, my question is about nested tables. Suppose I have a nested table:
    TYPE int_array IS TABLE OF INT;
    v_int_array int_array;
    Is there a built in function to allow me to search v_int_array for a specific integer value?
    George

    Use MEMBER OF operator:
    declare
        TYPE int_array IS TABLE OF INT;
        v_int_array int_array := int_array(1,2,3,4,5);
    begin
        if 1 member of v_int_array
          then
            dbms_output.put_line('Found it!');
        end if;
    end;
    Found it!
    PL/SQL procedure successfully completed.
    SQL> SY.

Maybe you are looking for

  • Printing a PDF document within a postscript file

    I know it is possible to print a PDF document from within a postscript file using Document Structuring Comments and Document Comment Extensions.  Is is possible to print a single page PDF document multiple times as a booklet?  For example I have a PD

  • Yosemite not completely installed?

    Downloaded and installed Yosemite but something is stuck with System Preferences.  Do I need to uninstall and download and install again?

  • XM to "any playable audio format" converter for Mac - where to find one?

    I have one .XM file, it is audio. I want to play it, but I have to convert it to something playable first. Any of you know a converter that works on a Mac?

  • Specification for the Web server

    Hi All, We have BW3.5. Presently web server is running in the production box itself. We are planning for a separate box for the Web server. Please give me the tips for the hardware config for the Webserver. Thanks Billy

  • Prerequiste checker for Secondary site 2012 Sp1

    Hello All, We want to install SCCM 2012 SP1 Secondary site from SCCM Primary console. We found out that we can run PreRequiste checker command from primary site server like below: ◦prereqchk.exe /SEC /Ssbport 4022 /SourceDir <Source Folder Path> I ha