How to upgrade to a nested Table of Types of legacy objects?

Anyone know why the (commented) next line does not work and what I can do? Is it possible to mount the column I'm trying to update? I think I'm going crazy...

create or replace type person_ot as an object (the varchar2 (10)) no final name.
/

create or replace type student_ot under person_ot (number s_num) not final;
/

Create type person_tt as table of the person_ot;
/

declare
lv_person_list person_tt;
lv_sql varchar2 (1000);
ref_cur sys_refcursor;
Start
lv_sql: = ' select new student_ot ('fred', 100) double
Union of all the
Select new student_ot ("sally", 200) of the double ';
--
Open the ref_cur for lv_sql;
collect the fetch ref_cur in bulk in lv_person_list;
close ref_cur;
--
dbms_output.put_line (lv_person_list. (Count);
for me in lv_person_list.first... loop of lv_person_list. Last
lv_person_list (i) .name: = initcap (lv_person_list (i) .name); -It works!
lv_person_list (i) .s_num: = 9999;  Why this line does not work and how do I update the s_num column? :-(
end loop;
end;
/

As default lv_person_list (i) is treated as person_ot object do not type student_ot. You must use a combination of a temporary object of type student_ot and TREAT the function:

declare
lv_person_list person_tt;
lv_sql varchar2(1000);
ref_cur sys_refcursor;
tmp student_ot;
begin
lv_sql:= 'select new student_ot(''fred'', 100) from dual
union all
select new student_ot(''sally'', 200) from dual';
--
open ref_cur for lv_sql;
fetch ref_cur bulk collect into lv_person_list;
close ref_cur;
--
dbms_output.put_line(lv_person_list.count);
for i in lv_person_list.first..lv_person_list.last loop
lv_person_list(i).name := initcap(lv_person_list(i).name ); -- This works!
tmp := treat(lv_person_list(i) as student_ot);
tmp.s_num := 9999;
lv_person_list(i) := tmp;
end loop;
end;
/
2

PL/SQL procedure successfully completed.

SQL> 

SY.

Tags: Database

Similar Questions

  • How can I change my nested table column?

    Hi all

    For example.

    Create Table MyTab
    (
    Number of Srno,
    SName varchar2 (100),
    Addr varchar2 (100)
    );

    This is my original table, but now I want to change my address of column in a nested table that having several columns in it.


    create or replace type AddrTyp as an object
    (
    LINE1 varchar2 (50).
    Line2 varchar2 (50).
    VARCHAR2 (50) line 3.
    4 varchar2 (50).
    line5 varchar2 (50).
    postadd varchar2 (10)
    );


    CREATE OR REPLACE
    TYPE DelAddr IS TABLE of the AddrTyp;


    It comes up ok but now I want to change my addr nested table column.

    as...


    ALTER table MyTab
    change the waterfall (DelAddr Addr);

    but it did not work.

    any idea?

    Indirectly!

    SQL> alter table MyTab add addr2 DelAddr NESTED TABLE addr2 STORE AS addr2_ntab;
    
    Table altered.
    
    SQL> alter table MyTab drop column addr;
    
    Table altered.
    SQL> alter table MyTab rename column addr2 to addr;
    
    Table altered.
    
    SQL> desc MyTab
     Name                                      Null?    Type
     ----------------------------------------- -------- -----------------
     SRNO                                               NUMBER
     SNAME                                              VARCHAR2(100)
     ADDR                                               DELADDR
    
    SQL>  
    
  • How to upgrade a 1 d table multiple graph/diagram of dispersion

    Hi, I am trying to add data to the chart single parcel you see below.  It is a 1 d array.  When I build another table to add to that, he becomes a 2d array and am not sure how to handle this data in another graph/chart.  I have a set x-scale-10 a-100 and at each iteration, about 100 values are inserted there to say-10 and - 20 (x scale) and so on until-100.  The chart will be of type point cloud.

    Any suggestions?

    Hey Grant,

    as I said: table of construction is required to create a 2D of your shift register. Change the default constant to a 1 d array!

  • How to upgrade several records or table using single update statement.

    Hello friends,

    I'm going to abc and xyz table.

    ABC: columns
    Ein, equipementid
    1-99999
    2 99999
    3 99999

    total records 1000

    columns of XYZ:
    Ein, equipementid
    1 1234
    2 3456
    2 4567
    4 4567

    total records 10000000

    I want equipmentid update table abc with equipmentid table xyz for ein game (like abc.ein = xyz.ein) and then had to delete record from table xyz corresponds to ein and equipentid who has updated the record in abc.

    Note: If you see xyz for ein table 2 we have two different equipmentid, we update with any value and only the record of xyz must be deleted once updated.

    A single declaration for the update and only statement needing to remove.

    Appreciate your help.



    Thank you / kumar

    Published by: kumar73 on August 2, 2012 13:02

    Maybe

    merge into abc
    using (select ein,max(equipmentid) equipmentid
             from xyz
            group by ein
          ) x
       on abc.ein = x.ein
     when matched
     then update
             set abc.equipmentid = x.equipmentid
    
    delete from xyz
     where exists(select null
                    from abc
                   where ein = xyz.ein
                     and equipmentid = xyz.equipmentid
                 )
    

    Concerning

    Etbin

  • How to upgrade the historic assignment table

    Guy

    I want to know the update of the table 'hri_mb_asgn_events_ct' request to maintain the assignment of current and former employees.


    Thank you

    The one I told you was update assignment events does not collect HRI assignment events fact (shared HR version).

    1. do you use shared HR?
    2. This Support Article Oracle help?
    3. What is your reason for wanting to fill hri_mb_asgn_events_ct?

    ORA-01452: cannot CREATE a UNIQUE INDEX. Duplicate keys found on HRI error load any assignment done events during the execution of a first load application Set [1270567.1 ID]

  • How to upgrade the user defined material cost type of cost specific org

    Hello

    We need to update material cost sub-elements of something to an org specific and defined by the user type of cost.
    I inserted a line of example in the CST_ITEM_CST_DTLS_INTERFACE and open interface "mass update material operating costs", but the program does not deal with all the lines, the rest 1 Process_flag.

    insert into cst_item_cst_dtls_interface
    (inventory_item_id,
    organization_id,
    id_ressource,
    usage_rate_or_amount,
    cost_element_ID,
    Process_Flag,
    last_update_date,
    last_updated_by,
    CREATION_DATE,
    created_by
    )
    values
    (96023,
    343,
    52538,
    0.00208012,
    1,
    1,
    SYSDATE,
    fnd_global.user_id,
    SYSDATE,
    fnd_global.user_id
    )

    Can someone help me with this, thanks.

    Concerning
    Yohan

    I think that there is some confusion.
    "Edit material costs of mass" program is used to apply the new rate of activity to the issue of costs. To do this, you don't have to insert records in the interface. You should define/update activity rates new use of the screen.

    To process the records in the interface of cost tables, you must run the program of 'importation cost process.

    For more details, see http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/cst/settas06.htm

    Hope that answers your question
    Sandeep Gandhi
    OMKAR Technologies Inc.
    Techno-Functional consultant

  • insertion in a nested table of pl/sql

    worm 10.2.0.3

    I know that I can do this in the example with a big collect but in the 'real' code, I have to be inserted...

    My question is how to insert in a nested table of pl/sql?
    create or replace type all_obj_obj as object(owner varchar2(30),object_name varchar2(30),object_type varchar2(30))
    /
    
    create or replace type all_obj_list as table of all_obj_obj
    /
    
    declare
     coll  all_obj_list := all_obj_list();
    begin
     insert into table(coll) select owner,object_name,object_type from all_objects;
    end;
    / 
    I know that could do a select master, object_name, object_type bulk collect in coll but I do an insert for some reason as long as I can go in... anyway to do it?

    Your "nested table" is not a "nested table" but a collection, a varable.
    Obviously so can not INSERT in a memory structure.
    Your need is not supposed, as BULK COLLECT would do the tric.
    As you cannot disclose why you ' need; for this (you do not have) and also do not mention a version, as you ' assume; PL/SQL does not ever change or everyone uses the same version, no additional help is possible.

    -----
    Sybrand Bakker
    Senior Oracle DBA

  • Inserting data in the nested table

    I explore the differences between the OBJECT and RECORD.

    As I'm still learning, I found that both are structures which essentially brings together different elements of types of different data or columns of data types, one is used in SQL and other is used in PL/SQL, please correct me if I'm wrong in my understanding.

    Below, I am trying to insert data into an array of type object, but I can't 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 the only purpose of the equivalent concept of SQL types of nested tables is to use one of the data types when you define an actual table?

    So-you can certainly use more that a simple "set an actual table. (I'm fairly certain that you can pass a table nested within a procedure, for example - try it, though - I'm not 100% sure on that - it just 'logic'.) If you can define a type, you can use it, pass it around, whatever.).

    Ariean wrote:

    And this nested table could be a record in SQL or object in PLSQL or simple data type (varchar number, etc.)?

    Nested tables are just like any other type of custom data. You can create a nested table of other types of data. You can create a custom of nested tables data type.

    Stupidly, he could become... uh, 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 is starting to hurt - I hope you get the idea

    Ariean wrote:

    Second is my understanding correct any OBJECT & RECORD?

    I see no benefit to describe another way.

  • How to get Nested table function

    Hi friends,

    In a package, I created a nested table type name Varchar2 EmployeeCodeList.

    Then, I created a function whose return type is EmployeeCodeList. But I don't get how to get the values of this function?

    TYPE EmployeeCodeList IS TABLE OF THE VARCHAR2 (30);

    FUNCTION GenerateRandomEcF (Ec_length NUMBER, NumberOfEmp NUMBER)

    < < the function code > >

    RETURN v_RandomEmpCodes;

    END GenerateRandomEcF;

    PROCEDURE GenerateEmpFile (NumberOfEmp NUMBER, Start_SN NUMBER, EmpValue NUMBER, VARCHAR2, VARCHAR2, Ec_length NUMBER EmpGroup HireDate) IS

    v_Filename VARCHAR2 (40);

    v_EmployeeCodes EmployeeCodeList;

    v_EmpBatchF UTL_FILE. TYPE_DE_FICHIER;

    BEGIN

    v_Filename: = 'EMPLOYEE_BATCH_ ' | TO_CHAR (SYSTIMESTAMP, 'YYYYMMDD_HHMISS'): '. DAT';

    v_EmployeeCodes: = EmployeeCodeList (NumberOfEmp);

    v_EmployeeCodes: = SELECT * FROM TABLE (GenerateRandomAcF (Ac_length, NumberOfVoucher));

    v_EmpBatchF: = UTL_FILE. FOPEN ('EXT_VOUCHER_DIR', v_Filename, 'W');

    IF UTL_FILE.IS_OPEN (v_EmpBatchF) THEN

    FOR i IN 1.NumberOfVoucher LOOP

    UTL_FILE. Put_line (v_EmpBatchF, v_EmployeeCodes (i) |) ',' || Start_SN + (i-1). «, » || EmpValue | «, » || HireDate. «, » || EmpGroup);

    END LOOP;

    END IF;

    END GenerateEmpFile;

    How the line highlighted code above must be written so that I can get value of function in a variable of the same type of nested table.

    If you use the second approach, I mean

    56 v_EmployeeCodes: = GenerateRandomAcF (Ac_length, NumberOfEmployee);

    then the collection must be initialized using the constructor method. Change line 33.48 as number below

    33 v_RandomEmployeeCodes EmployeeCodeList: = EmployeeCodeList();

    48 v_EmployeeCodes EmployeeCodeList: = EmployeeCodeList();

    This is because when you use BULK COLLECT, Oracle automatically populates the collection without initialization. But if you do not COLLECT in BULK, then the collection must be initialized before filling / extending. Otherwise, you will get error of REFERENCE to the COLLECTION that is not INITIALIZED. So this should be the code, you should use. When you do not select... INTO, you might well declare the function is private and it is not necessary to declare in the package specification.

    SQL > CREATE OR REPLACE PACKAGE BODY GenerateEmployeePackage AS

    2 PROCEDURE Get_AC_Range (Ac_length NUMBER, Range_Start SERIES, certain Range_End NUMBER)

    3 EAST

    4 BEGIN

    5 If Ac_length = 8 THEN

    6 Range_Start: = 10000000;

    7 Range_End: = 99999999;

    8 Ac_length ELSIF = 9 THEN

    9 Range_Start: = 100000000;

    10 Range_End: = 999999999;

    11 Ac_length ELSIF = 10 THEN

    12 Range_Start: = 1000000000;

    13 Range_End: = 9999999999;

    14 Ac_length ELSIF = 11 THEN

    15 Range_Start: = 10000000000;

    16 Range_End: = 99999999999;

    17 ELSIF Ac_length = 12 THEN

    18 Range_Start: = 100000000000;

    19 Range_End: = 999999999999;

    20 Ac_length ELSIF = 13 THEN

    21 Range_Start: = 1000000000000;

    22 Range_End: = 9999999999999;

    23 Ac_length ELSIF = 14 THEN

    24 Range_Start: = 10000000000000;

    25 Range_End: = 99999999999999;

    26 END IF;

    27 END Get_AC_Range;

    28

    GenerateRandomAcF FUNCTION 29 (Ac_length NUMBER, NumberOfEmployee NUMBER)

    30 BACK IS EmployeeCodeList

    31 NUMBER Range_Start;

    32 Range_End NUMBER;

    33 v_RandomEmployeeCodes EmployeeCodeList: = EmployeeCodeList ();

    BEGIN 34

    35 Get_AC_Range (Ac_length, Range_Start, Range_End);

    36 v_RandomEmployeeCodes.extend (NumberOfEmployee);

    37

    38 FOR I IN 1.NumberOfEmployee LOOP

    39 v_RandomEmployeeCodes (i): = TRUNC (DBMS_RANDOM.value (down-online Range_Start, high-online Range_End));

    40 END LOOP;

    41

    42 v_RandomEmployeeCodes RETURN;

    43

    END 44 GenerateRandomAcF;

    45

    GenerateEmployeeFile PROCEDURE 46 (NumberOfEmployee NUMBER of Start_SN NUMBER, EmployeeValue NUMBER, displayed EmployeeGroup VARCHAR2, VARCHAR2, Ac_length NUMBER) IS

    47 v_Filename VARCHAR2 (40);

    48 v_EmployeeCodes EmployeeCodeList: = EmployeeCodeList ();

    49 v_EmployeeBatchF UTL_FILE. TYPE_DE_FICHIER;

    BEGIN 50

    51 v_Filename: = 'Employee_BATCH_ ' | TO_CHAR (SYSTIMESTAMP, 'YYYYMMDD_HHMISS'): '. DAT';

    52 v_EmployeeCodes: = EmployeeCodeList();

    53

    54 get nested table function

    55 - SELECT * COLLECT in BULK IN TABLE v_EmployeeCodes (GenerateRandomAcF (Ac_length, NumberOfEmployee));

    56 v_EmployeeCodes: = GenerateRandomAcF (Ac_length, NumberOfEmployee);

    57 v_EmployeeBatchF: = UTL_FILE. FOPEN ('EXT_Employee_DIR', v_Filename, 'W');

    58

    59 if UTL_FILE.IS_OPEN (v_EmployeeBatchF) THEN

    60. FOR i IN v_EmployeeCodes.FIRST... v_EmployeeCodes.Last LOOP

    UTL_FILE 61. Put_line (v_EmployeeBatchF, v_EmployeeCodes (i) |) ',' || (Start_SN + (i-1)). «, » || EmployeeValue | «, » || Posted | «, » || EmployeeGroup);

    LOOP END 62;

    63 END IF;

    64

    END 65 GenerateEmployeeFile;

    66

    END 67 GenerateEmployeePackage;

    68.

  • How to assign values to the nested table and passes as a parameter for the procedure?

    How to assign values to the nested table and passes as a parameter for the procedure?

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type1 is table of the test_object1;


    create or replace type test_object2 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type2 is table of the test_object2;


    GRANT ALL ON test_object1 to PUBLIC;


    GRANT ALL ON test_type1 to PUBLIC;


    GRANT ALL ON test_object2 to PUBLIC;


    GRANT ALL ON test_type2 to PUBLIC;

    Here is the table object type:

    create the table test_object_tpe
    (
    sl_num NUMBER,
    Description VARCHAR2 (100),
    main_val1 test_type1,
    main_val2 test_type2
    )


    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS earlier2;


    -----------------------------------------------------------------------------------------------------------

    Here is the procedure that inserts values into the nested table:

    PROCEDURE INSERT_TEST_DATA (sl_num in NUMBER,
    Description in VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    )
    IS
    BEGIN

    FOR rec in p_main_val1.first... p_main_val1. Last
    LOOP

    INSERT INTO xxdl.test_object_tpe
    (
    sl_num,
    Description,
    main_val1,
    main_val2
    )
    VALUES
    (
    sl_num
    description
    test_type1 (test_object1)
    p_main_val1 .val1 (CRE),
    p_main_val1 .val2 (CRE),
    p_main_val1 .val3 (rec)
    )
    )
    test_type2 (test_object2 (p_main_val2 .val1 (CRE),
    p_main_val2 .val2 (CRE),
    p_main_val2 .val3 (rec)
    )
    )

    );

    END LOOP;

    commit;

    END INSERT_TEST_DATA;

    -------------------------------------------------------------------------------------------

    Here are the block anonymoys what values attributed to the object type and pass values in the procedure:

    Set serveroutput on;

    declare

    p_sl_num NUMBER: = 1001;
    p_description VARCHAR2 (50): = 'Test Val1;

    inval1 test_type1: = test_type1();
    inval2 test_type2: = test_type2();

    Start


    inval1 (1) .val1: = "testx1";
    inval1 (1) .val2: = "testx2";
    inval1 (1) .val3: = "testx3";

    inval2 (1) .val1: = "testy1";
    inval2 (1) .val2: = "testy2";
    inval2 (1) .val3: = "testy3";

    CSI_PKG. INSERT_TEST_DATA (sl_num = > p_sl_num,)
    Description = > p_description,
    p_main_val1 = > inval1,
    p_main_val2 = > inval2
    );

    end;
    /
    Someone can correct me.

    Thank you
    Lavan

    Thanks for posting the DOF and the sample code but whenever you post provide your Oracle version 4-digit (result of SELECT * FROM V$ VERSION).
    >
    How to assign values to the nested table and passes as a parameter for the procedure?
    >
    Well you do almost everything bad that could be hurt.

    Here is the code that works to insert data into your table (the procedure is not even necessary).

    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    
    INSERT INTO test_object_tpe
    (
    sl_num,
    description,
    main_val1,
    main_val2
    )
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /
    

    See example 5-15 making reference to an element of nested Table Chapter 5 using PL/SQL collections and records in the PL/SQL doc
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJABEBEA

    1. you don't even have the procedure because it is a simple INSERTION in the table you can do directly (see my above code)

    inval1(1).val1 := 'testx1';
    

    Since you have not yet created all the elements, there is no element 1 "inval1". You need EXTEND the collection to add an element

    inval1.extend();
    

    And then, there is an empty element, but "inval1" is a container for objects of type 'test_object1' not for scalars as "val1", "val2", and "val3".
    If you can not do

    inval1(1).val1 := 'testx1';
    

    You must create an instance of 'test_object1 '.

    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    

    And so on for the other collection

    You don't need the procedure (as my code example shows), but once you fill in the variables correctly it will work.

  • How the nested table that is stored in the database?

    How the nested table that is stored in the database?
    The nested table column is stored with the table main or separate in the database?

    A nested table is a table that is stored in the structure of another table. It is used to support the columns that contain multivalued attributes.

    If you want to use the same type in multiple places, create them on a global scale and these will be discussed under 'Types'.

  • How to reference a column internal table nested - without a name?

    Hi guys, I have a question about nested tables - Ive searched around and cannot find an answer.

    Here is my sample code:
    CREATE OR REPLACE TYPE scotttype AS table of number;
    
    create table scott1 (col_a varchar2(10), col_b scotttype) nested table col_b store as col_b
    
    insert into scott1 values ('onetwo',scotttype(1,2))
    
    insert into scott1 values ('threefour',scotttype(3,4))
    
    select t1.col_a, column_value col_b
    from scott1 t1, TABLE(t1.col_b) t2
    
    insert into table(select s.col_b FROM scott1 s WHERE s.col_a = 'onetwo')
    values (5);
    OK, so that sounds great.

    If I want to do an update or delete however, how can I make reference to col_b that the nested table doesn't have a column name?
    That is to say:

    update table(select col_b from scott1 where col_a = 'onetwo') col_b
    set col_b.XXXXX = 6
    where col_b.XXXXX = 5
    will then not work what should I put instead of the XXXXX?


    I'm sure its simple but I can't!

    Thank you all
    SQL> select t1.col_a, column_value col_b
      2  from scott1 t1, TABLE(t1.col_b) t2;
    
    COL_A           COL_B
    ---------- ----------
    onetwo              1
    onetwo              2
    threefour           3
    threefour           4
    onetwo              5
    
    SQL> commit;
    
    Commit complete.
    
    SQL> update table(select col_b c1 from scott1 where col_a = 'onetwo') t1
      2  set column_value = 6
      3  where column_value= 5;
    
    1 row updated.
    
    SQL> commit;
    
    Commit complete.
    
    SQL>  select t1.col_a, column_value col_b
      2   from scott1 t1, TABLE(t1.col_b) t2;
    
    COL_A           COL_B
    ---------- ----------
    onetwo              1
    onetwo              2
    threefour           3
    threefour           4
    onetwo              6
    
    SQL> 
    
  • How can you add item (object) complex "nested table"?

    Hello I did some reading on * "Associative" * and * "Nested Table" * and I would like to enumerate the collection using the later version (http://www.devshed.com/c/a/Oracle/Database-Interaction-with-PLSQL-Nested-Tables/2/)
    -know list "Nested Table"

    However, encountered problem try to * 'EXTEND' * my nested table (add items to the complex type or OBJECT I defined, namely 'TmpHierarchyMapObjType' below) - detail as follows:

    -NOTE 1: Here's how to create the type object (be well if I just say "CREATE or REPLACE TYPE TmpHierarchyMapObjType AS OBJECT (_TMP_HIERACHICAL. ROWTYPE_)"instead of having to duplicate the column definition.
    CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
    (
    ID numeric (19.0),.
    ParentId numeric (19.0),.
    ChildId numeric (19.0),.
    ...
    TmpUID varchar2 (32),
    ReferencedId numeric (19.0),.
    ...
    );

    -NOTE 2: I can't put 'TmpHierarchyMapObjType' inside the package, but it's not crucial, I guess.
    Types of CREATE or REPLACE PACKAGE
    AS
    TYPE cursorType IS REF CURSOR;
    TYPE TmpHiearchyMapTableType IS TABLE OF THE TmpHierarchyMapObjType; / * Use 'Nested Table' instead of an associative array * /.
    / * TYPE TmpHiearchyMapTableType IS TABLE OF THE TMP_HIERARCHYMAP % ROWTYPE INDEX DIRECTORY. */
    END;

    -NOTE 3: Here is my FUNCTION TABLE that now returns a "Nested Table" as assumed to 'Associative' (with a syntax different enumeration)
    FUNCTION to CREATE or REPLACE spGetParentsTable
    (
    Number to the ObjectId,
    ObjectClassifier varchar2
    )
    RETURN types . TmpHiearchyMapTableType -now a 'Nested Table', not 'voluntary '.
    IS
    Types of TmpHierarchyMap. TmpHiearchyMapTableType;
    ThisTempId varchar2 (32);
    CURSOR spGetParents_cursor IS
    SELECT
    ReferencedId Id,
    ParentId,
    ChildId,
    ...
    OF TMP_HIERARCHYMAP
    WHERE TmpUID = ThisTempId;
    BEGIN
    SELECT sys_guid() IN the double ThisTempId;

    spRecursiveGetParents (ObjectId, ObjectClassifier, ThisTempId);

    -(Commentary) TmpHierarchyMapMAX: = 0;
    FOR oMap in spGetParents_cursor LOOP
    -(Commented out) TmpHierarchyMapMAX: = TmpHierarchyMapMAX + 1;

    -QUESTION: FAILED here! How can I add/elements of complex types?
    TmpHierarchyMap.EXTEND (cast (oMap as TmpHierarchyMapObjType));

    /*
    NOTE: (In the comment) use is not "Associative", now using "nested table" instead.
    TmpHierarchyMap (TmpHierarchyMapMAX). ID: = oMap.Id;
    TmpHierarchyMap (TmpHierarchyMapMAX). ParentId: = oMap.ParentId;
    TmpHierarchyMap (TmpHierarchyMapMAX). ChildId: = oMap.ChildId;
    ...
    */
    END LOOP;

    DELETE FROM TMP_HIERARCHYMAP WHERE TmpUID = ThisTempId;

    RETURN TmpHierarchyMap;

    END spGetParentsTable;

    -Finally, I would like to enumerate the nested table.
    DECLARE
    types of oMappingTable. TmpHiearchyMapTableType;
    BEGIN

    oMappingTable: = spGetParentsTable(2,'ThinkFundamentals.Util.Security.SystemUser');

    -NOTE 4: this is my final goal!
    Select * from table (cast (oMappingtable as types.) TmpHiearchyMapTableType));

    dbms_output.put_line ('done!');
    END;


    REF:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/Collections.htm#LNPLS005
    http://www.DevShed.com/c/a/Oracle/associative-arrays-in-Oracle-PLSQL-introduction/2/
    http://www.DevShed.com/c/a/Oracle/database-interaction-with-PLSQL-nested-tables/2/

    Hello

    Try this,

    TmpHierarchyMap.Extend();
    TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id
                                                                    , oMap.ParentId
                                                                    , ... );
    

    Kind regards

    Christian Balz

  • How to fill the value in the nested table by using the object type


    Hi gurus

    I created an object type and able to fill the values in it, now I want to create a nested table type of this object and fill it but looks like I'm doing something wrong, see my code below.

    Code example

    CREATE or REPLACE TYPE countries_o
    AS
    OBJECT
    (
    COUNTRY_ID TANK (2 BYTES),
    COUNTRY_NAME VARCHAR2 (40 BYTE),
    REGION_ID NUMBER);
    /

    create or replace type countries_t is table of the countries_o;

    /

    CREATE OR REPLACE

    ABC of the PROCEDURE

    IS

    v_print countries_t; -: = arr_countries_t('01','Aus',1);

    BEGIN

    v_print: = countries_t('01','A',11);

    DBMS_OUTPUT. Put_line (v_print. COUNTRY_ID | v_print. COUNTRY_NAME | v_print. REGION_ID);

    END;

    /

    Error

    • Error (6.3): PL/SQL: statement ignored
    • Error (6,12): PLS-00306: wrong number or types of arguments in the call to 'COUNTRIES_T '.
    • Error (7.3): PL/SQL: statement ignored
    • Error (7.32): PLS-00302: component 'COUNTRY_ID' must be declared

    Thanks in advance

    Concerning

    Muzz

    Hi user,

    Here is another method that you can try-

    CREATE OR REPLACE

    ABC of the PROCEDURE

    IS

    v_print countries_t: = countries_t (countries_o('01','A',11));

    BEGIN

    DBMS_OUTPUT. Put_line (v_print (1).) COUNTRY_ID | v_print (1). COUNTRY_NAME | v_print (1). REGION_ID); -you're accessinf the first element of the nested table, which in turn points to the object.

    END;

    In the sections of the declaration you have assigned values to the nested table.

    Kind regards
    Maxou

  • How to remove the space between the nested tables.

    I'm not able to line up the parts of the nested table side by side without a big white space. You are using Mac OS 10, DW CS 6. link to pageScreen Shot 2015-06-03 at 10.44.50 PM.png

    Thank you very much. J

    It's just terribly, terribly code.

    You should not be using heights or split cells in a table.

    The cause of your 'current' issue is through the establishment of a height on yourcell:

Maybe you are looking for