Type attribute with Object type or Nested table?

I have been creating lot many threads around the same problem, however i thought i knew but realized I do not know or else do not know how to..
I have created object type with an attribute READINGVALUE NUMBER(21,6)...How can i use type attribute on this object while declaring variable.....can we use type attribute on NESTED TABLES, similar to the db tables?
example
CREATE TYPE READING AS OBJECT(READINGVALUE NUMBER(21,6));
CREATE TABLE INTERVALREADINGS OF TYPE READING;

meghavee wrote:
Thanks Solomon, however this approach does not preserve precision/scale of number data type.....What you can do is create placeholder tables:
SQL> create table reading_type_placeholder of reading
  2  /
Table created.
SQL> desc reading_type_placeholder
Name                                      Null?    Type
READINGVALUE                                       NUMBER(21,6)
SQL> declare
  2      v_var reading_type_placeholder.readingvalue%type;
  3  begin
  4      v_var := 123456789012345;
  5  end;
  6  /
PL/SQL procedure successfully completed.
SQL> declare
  2      v_var reading_type_placeholder.readingvalue%type;
  3  begin
  4      v_var := 1234567890123456;
  5  end;
  6  /
declare
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at line 4
SQL>And if you modify type attribute:
SQL> alter type reading modify attribute readingvalue number(26,6) cascade;
Type altered.
SQL> desc reading_type_placeholder
Name                                      Null?    Type
READINGVALUE                                       NUMBER(26,6)
SQL>SY.

Similar Messages

  • JDBC & changed object type in nested table

    Once I add new column in object type in nested table.. I did step by step like it was wrinten in OraDoc..convert data e.t.c
    All programs work fine exept JDBC drivers..I decompile it and it's crashing on oracle.sql.ArrayDescriptor.java in metod
    private int toLengthFromLocator(byte abyte0[])
    after trying to execute this strane query in this method:
    oraclepreparedstatement = (OraclePreparedStatement)m_conn.prepareStatement("SELECT count(*) FROM TABLE( CAST(? AS " + getName() + ") )");
    this method exist and crash in 90 and 92 drivers.. maybe oracleTypeCOLLECTION.java
    public Datum unlinearize(byte abyte0[], long l, Datum datum, long l1, int i, work incorrect.. and cause call of this method..
    2driver developers: please trace your code with changed nested table

    damn... nobody reply me.. but this bug fixed on metalinc..

  • UserDefined Type Question - Nested Table Attribute

    I have a question about some types I'm trying to create and whether or not it's even possible .....
    Here's the background ...
    I have the following type i created :
    create type asset_stat (
    stat_current varchar2(50),
    stat_change_date date,
    stat_change_user varchar2(30)
    All this type does is simply put a user and date/time stamp when constructed. I want to track status changes for historical tracking.
    Then I want to create a nested table type of the above type as follows:
    create type asset_stat_nt as table of asset_stat
    Then, I have another type i've created which will have the nested table type created above as an attribute.
    create type asset (
    asset_name varchar2(30),
    asset_type varchar2(3),
    asset_stat asset_stat_nt
    Now, the constructor for this asset type is defined like this: ( this is where i get lost)
    constructor function asset (
    asset_nm IN varchar2,
    asset_type_cd in varchar2,
    asset_stat_cd in varchar2 ) return self as result is
    begin
    self.asset_nm := asset_nm
    self.asset_type := asset_type_cd ;
    self.asset_stat := asset_stat_nt(asset_stat_cd);
    return;
    end;
    I just created a table of asset type and tried to do an insert and I'm getting an error related to the line where the nested type is being assigned. Is this possible? If so is my syntax completely off? I'm not quite sure how to set values for the nested type because i want to keep all records of change. Any help would be greatly appreciated.
    thanks

    the block of code shows that asset_stat_nt is the type assigned to asset_stat inside the type asset as shown below
    create type asset (
    asset_name varchar2(30),
    asset_type varchar2(3),
    asset_stat asset_stat_nt
    I guess for the following block of code, the line with the arrows should be given like shown below in bold letters
    constructor function asset (
    asset_nm IN varchar2,
    asset_type_cd in varchar2,
    asset_stat_cd in varchar2 ) return self as result is
    begin
    self.asset_nm := asset_nm
    self.asset_type := asset_type_cd ;
    self.asset_stat := asset_stat_nt(asset_stat_cd);return;
    end;
    [b][b]self.asset_stat := asset(asset_stat_nt(asset_stat_cd));
    I am not pretty sure.......try it anyway.....if it works....good to you

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

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

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

  • Help with updating in out nested table parameter

    I've been asked a question by a workmate, but I haven't been able to help him.
    He's got these types:
    CREATE OR REPLACE TYPE TP_COLTYPE AS OBJECT (
      parametro varchar2(30 byte),
      rango  number(12,2),
      color  varchar2(15 byte)
    CREATE OR REPLACE TYPE TP_COLTYPE_TAB AS TABLE OF TP_COLTYPE;
    CREATE OR REPLACE TYPE TP_PARTYPE AS OBJECT (
      perfil_comercial VARCHAR2(30),
      subtendido VARCHAR2(2),
      parametros TP_COLTYPE_TAB
    /And he wants to create a procedure that has IN OUT TP_PARTYPE paramter so that he can modify the color column in all the records in the array. This is his try (which fails to compile):
    CREATE OR REPLACE PROCEDURE getColoresUmbrales(p_parametros IN OUT TP_PARTYPE) IS
        CURSOR c_partype IS SELECT parametro,rango FROM TABLE(p_parametros.parametros) FOR UPDATE;
    BEGIN
        FOR r_partype IN c_partype LOOP
            UPDATE TABLE(p_parametros.parametros)
                SET color = getColorUmbral(p_parametros.perfil_comercial,p_parametros.subtendido,r_partype.parametro,r_partype.parametro)
             WHERE CURRENT OF c_partype;
        END LOOP;
    EXCEPTION WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20000,SQLERRM);
    rollback;
    END getColoresUmbrales;I don't think using a cursor is necessary nor efficient, but I have not managed to find the right way. I don't know what release he's working wiht, but I know it is 10g.
    Could someone please help us?

    I have coded this procedure which should do what we want:
    CREATE OR REPLACE PROCEDURE getcoloresumbrales_fernando (
       p_parametros   IN OUT   tp_partype_prueba_fernando
    IS
    BEGIN
       FOR i IN 1 .. p_parametros.parametros.COUNT
       LOOP
          p_parametros.parametros (i).color :=
             getColorUmbral (p_parametros.perfil_comercial,
                                    p_parametros.subtendido,
                                    p_parametros.parametros (i).rango,
                                    p_parametros.parametros (i).rango
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          raise_application_error (-20000, SQLERRM);
          ROLLBACK;
    END getcoloresumbrales_fernando;
    /But, how can I bulk it?
    Thanks in advance.

  • Nested tables of user defined types

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

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

  • Creating a type having a nested table of that type !!!!!

    Hi all, my question may look ambigious, but it's better understood by this example: How can i do this??
    CREATE TYPE MaterialType AS OBJECT (
         MaterialID          NUMBER,
         MaterialName          varchar2(20),
         CompatibleMaterials     MaterialsNT
    CREATE TYPE MaterialsNT AS TABLE OF REF MaterialType;
    In other words, how can i create 'MaterialType', having as attribute 'CompatibleMaterials', which is a nested table of 'MaterialType'

    why don't you try nested tables?
    prem

  • Please help with multiple insert query into nested table!!!!

    I am having a problem with inserting multiple references to objects into a nested table using the following query:
    INSERT INTO TABLE(SELECT Taken_by FROM courses WHERE course_number= 001)
    (SELECT REF(p) FROM persons p
    WHERE p.enroled_in = 'Computing for Business'
    The database says that p.enroled_in is an invalid identifier. I know why this is. This is because the field enroled_in is part of a subtype of person called student_type and the query above is not accounting for this properly. I would like to know the correct syntax to use so I can insert into the nested table wherever a student is enroled into the 'computing for business' course. My full schema is below:
    CREATE TYPE person_type;
    CREATE TYPE student_type;
    CREATE TYPE staff_type;
    CREATE TYPE course_type;
    CREATE TYPE module_type;
    CREATE TYPE address_type AS OBJECT
    Street VARCHAR2 (30),
    Town     VARCHAR2 (30),
    County VARCHAR2 (30),
    Postcode VARCHAR2 (9)
    CREATE TYPE person_type AS OBJECT
    Name VARCHAR2 (50),
    Address address_type,
    DOB     DATE
    ) NOT FINAL;
    CREATE TYPE staff_type UNDER person_type
    Staff_number NUMBER (2,0)
    ) FINAL;
    CREATE TYPE student_type UNDER person_type (
    Student_number NUMBER (2,0),
    Enroled_in VARCHAR2(50),
    MEMBER FUNCTION getAge RETURN NUMBER
    )NOT FINAL;
    CREATE OR REPLACE TYPE BODY student_type AS
    MEMBER FUNCTION getAge RETURN NUMBER AS
    BEGIN
    RETURN Trunc(Months_Between(Sysdate, DOB)/12);
    END getAge;
    END;
    CREATE TYPE module_type AS OBJECT
    Module_number VARCHAR2(6),
    Module_name VARCHAR2(50),
    Credit NUMBER(2,0),
    Taught_in VARCHAR2(50)
    CREATE TYPE students_tab AS TABLE OF REF person_type;
    CREATE TYPE modules_tab AS TABLE OF REF module_type;
    CREATE TYPE course_type AS OBJECT
    Course_number NUMBER (2,0),
    Course_name VARCHAR2(50),
    Dept_name VARCHAR2(50),
    Taken_by Students_tab,
    Contains Modules_tab
    CREATE TABLE modules OF module_type(
    constraint pk_modules primary key (Module_number)
    CREATE TABLE courses OF course_type(
    constraint pk_courses primary key (Course_number)
    NESTED TABLE Taken_by STORE AS students_nt,
    NESTED TABLE Contains STORE AS modules_nt;

    By the way I am using oracle 9i and trying to insert into the nested table data from a subtype (i.e student is a subtype of person)

  • HOW TO PLAY WITH NESTED TABLES

    Hi Sir,
    It would be pleasure to get any suggestion to know why i am geting following error and how to solve this problem ?
    Error Message: JBO-27122: SQL error during statement preparation. Statement: SELECT REF(ExperienceTab), ExperienceTab.SYS_NC_OID$ FROM EXPERIENCE_TAB ExperienceTab
    SCENERIO IS LIKE : I m trying to create Business Components .JSP Appl using wizard and then select view objects which has nested table. it is generated successful.
    NOW when i try to run it is executing without any errors but it doesn't show any object of nested table. THEN i decide to select nested tables to generate ViewObjects of business components and then generate .JSP file but when i try to execute application to see the result of .JSP pages which has been generated by viewobjects. And this viewobject is generated by the nested tables the above error occurs. I am quite new in Jdev enviornment , your suggestion will be higly appreciated.
    I hope my explaination is sufficient to know problem.
    Thank you very much.
    Musahib : [email protected]
    null

    Hi Sir,
    It would be pleasure to get any suggestion to know why i am geting following error and how to solve this problem ?
    Error Message: JBO-27122: SQL error during statement preparation. Statement: SELECT REF(ExperienceTab), ExperienceTab.SYS_NC_OID$ FROM EXPERIENCE_TAB ExperienceTab
    SCENERIO IS LIKE : I m trying to create Business Components .JSP Appl using wizard and then select view objects which has nested table. it is generated successful.
    NOW when i try to run it is executing without any errors but it doesn't show any object of nested table. THEN i decide to select nested tables to generate ViewObjects of business components and then generate .JSP file but when i try to execute application to see the result of .JSP pages which has been generated by viewobjects. And this viewobject is generated by the nested tables the above error occurs. I am quite new in Jdev enviornment , your suggestion will be higly appreciated.
    I hope my explaination is sufficient to know problem.
    Thank you very much.
    Musahib : [email protected]
    null

  • Error while mapping two times nested table

    Hi,
    I have a Product table which has nested ProductSubcategory in it.
    ProductSubcategory nested table also has nested table ProductCategory inside it.
    So there is a nested table inside nested table.
    I designed a dimension on warehoue builder and while mapping, i got "ORA-22913: must specify table name for nested table column or attribute" error.
    I mapped nested tables before with using varray iterator and expand object, but they were nested once. Is there any solution for mapping two or more time nested tables?
    Now i exracted tables and i continuou working but, i wondered is there any way.
    Creation codes are below. Thanx :)
    CREATE TABLE PRODUCT
    (     PRODUCTID NUMBER NOT NULL ,
         ProductSubcategory ProductSubcategory,
         MODIFIEDDATE DATE NOT NULL)
    NESTED TABLE ProductSubcategory STORE AS ProductSubcategory_TABLE
    ( NESTED TABLE ProductCategoryId STORE AS ProductCategory_TABLE);
    CREATE TYPE TYPE_ProductSubcategory AS OBJECT (
         ProductSubcategoryID number ,
         ProductCategoryId ProductCategory ,
         Name Varchar(50) ,
         rowguid varchar2(100) ,
         ModifiedDate date );
    CREATE TYPE TYPE_ProductCategory AS OBJECT (
         ProductCategoryID number ,
         Name Varchar(50) ,
         rowguid varchar2(100) ,
         ModifiedDate date );

    Bharadwaj Hari wrote:
    Hi,
    I agree with u...I am not sure of the environment the user has so i put forth all the 3 option that crossed my mind that time....thats why i said he has to choose what best suits him/her...
    Also if the database is huge and we create physical temp tables (option 2 and ur idea) its like having redundant data in the database which is also a problem....So ist upto the user to actually evaluate the situation and come up with what best suits him/her...
    Regards
    BharathHi,
    I understand your opinion. But I am not sure that the user have enough experience to choose the best option by his one. And about the redundant data: because of this I wrote that he should truncate the tables after the last mapping which loads all data into the real target table.
    Regards,
    Detlef

  • 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

  • Returning a nested table in a constructor function

    Hi there is it possible to return a nested table in a Constructor Function or do I need to create a package?
    I have this package spec it gives me an error
    create or replace type
    INTERFACE.PDE_BKRF_NTB
    as table of
    PDE_BKRF_TYP,
    -- Define a constructor for REF_TYP_CD and REF_KEY to return a list.
    constructor function
    PDE_BKRF_TYP
    (P_REF_TYP_CD varchar2
    ,P_REF_KEY number
    ,P_EXTR_DT date)
    return SELF as result
    /

    No, a NESTED TABLE type can't have a constructor I think.
    Check the documentation:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_8001.htm#i2121881
    It distinguishes between object type, varray type and nested table type. Only object types can have constructors.
    As a workaround you could create another object type that has an attribute of your nested table type:
    Note: untested code
    create or replace type
    INTERFACE.PDE_BKRF_NTB
    as table of
    PDE_BKRF_TYP;
    create or replace type INTERFACE.PDE_BKRF_NTB_2
    as object (
    a INTERFACE.PDE_BKRF_NTB,
    constructor function
    PDE_BKRF_NTB_2
    (P_REF_TYP_CD varchar2
    ,P_REF_KEY number
    ,P_EXTR_DT date)
    return SELF as result)
    create or replace type body INTERFACE.PDE_BKRF_NTB_2
    as
    constructor function
    PDE_BKRF_NTB_2
    (P_REF_TYP_CD varchar2
    ,P_REF_KEY number
    ,P_EXTR_DT date)
    return SELF as result as
    /Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Query nested table?

    Let's say I have an object type "pair" with elements "name" and "value". I create a nested table type "pairtable" of type "pair". Then I create a view, "view", that has a column "nametable". The values in "nametable" are the result of a function that takes the value in the first column of the view, "id", and builds a nested table of type "pairtable" with the "names" and "values" associated with "id" that are stored in other tables. Clear as mud, yes?
    If I type this into SQL+
    select * from view where id = 100
    I get
    id col2 col3 col4 nametable
    100 A B C pairtable(pair(aname, avalue)),pairtable(pair(bname, bvalue)),...
    What I want is a cursor that contains only the "names" and "values" from a select number of "id"s.
    What is the syntax?
    Database is 8i, client is 9.2.
    (p.s. Eventually I will want to call these name value pairs from .NET as a REF Cursor. For now I will settle for something that works in PL/SQL)

    Ross,
    OLEDB does not support object types or nested table. This restriction is limited by the Microsoft OLEDB specfication.
    This forum is for ODP.NET. You may want to post this question to OLEDB forum.
    Thanks
    Martha

  • Inserting Data into nested table

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

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

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

Maybe you are looking for