Use of the TYPE AS OBJECT and ARRAY OF

Hi all

The code that I'm checking has:
------------------------------------------------------------------------------------

CREATE OR REPLACE
TABLE AS ROLE_TABTYPE TYPE OF ROLE_TYPE;

CREATE OR REPLACE
OBJECT OF TYPE ROLE_TYPE AS
(
ROLE_CD VARCHAR2 (20));

-----------------------------------------------------------------------------------
Now that ROLE_TABTYPE is used in many ways for example a procedure that updates all the roles assigned to the user as follows:
-----------------------------------------------------------------------------------------------------------------------------
PROCEDURE pr_update_user_role
(..., ip_role_array IN role_tabtype,...,...) AS
BEGIN
...
..
FOR l_cnt IN ip_role_array. FIRST... ip_role_array. LAST
LOOP
INSERT INTO cdr_md_user_role (cdr_md_user_role_seq_no,
role_cd,
user_id)
VALUES (cdr_md_user_role_seq. NEXTVAL,
.role_cd ip_role_array (l_cnt),
ip_user_id);
...
AT THE END:
----------------------------------------------------------------------------------------------------------------------------
I don't understand what is this ip_role_array and how it is assigned to ROLE_TABTYPE.
I read documents to understand the use of these collections, but could not get.

Please, help me to understand this.

Rgds,
Aashish

It is just a collection (table): this is a variable that contains several values that are accessible using (1), etc. (2) refer to each value. This allows the calling procedure pass a set of values and have the loop of the procedure through the table and deal with each in turn. In case it starts with (1), ip_role_array. FIRST gives the first number of the element and ip_role_array. LAST give the last, so if there are 25 values in table 1, then the loop will be assessed as FOR l_cnt IN 1.25 LOOP.

http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/Collections.htm
http://www.williamrobertson.NET/documents/collection-types.html

Edited by: William Robertson on December 31, 2009 12:13

Tags: Database

Similar Questions

  • SELECT the type of object and

    Hello

    I created the following: object_type and table
    create or replace type subscription_type as object
    (street varchar2 (20),)
    No varchar2 (5));

    create table test
    (integer id, address subscription_type);
    Insert in the test
    values (1, subscription_type (' x-test ', ' 1' ");)

    and I want to choose only the id and the street of the test of the table.
    How can I do this?

    Thank you

    : D

    Others agree as well with your description.

    A few recent examples:
    Forums should have a button {code}
    OTN Forum FAQ

    For the OP:
    Just use the {noformat

    {noformat} tag, put it before and after your sample code.
    So, when you type or copy/paste this:
     {noformat}
    

    Select *.
    Double;

    {noformat}
    it will appear as:
    

    Select *.
    Double;

    on this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    
  • spreadsheet charger error: the type of person of the system shall be used when the type of assignment is E or AND

    Hello

    I am trying to load data through loader of worksheet in Fusion HCM (worker load) but I get this error message

    «Error: the type of person of the system shall be used when the type of assignment is E or AND.»

    Any ideas?

    Thank you

    Soha.

    Solve us it

    2 types of person had used default type punctual person

  • What is the difference between the type of table and view?

    Hello world.

    What is the difference between the type of view and table that we can set using SQL statement such as: "tab type is table of...» » ?

    A view is a stored query.

    An array type is a construction of PL/SQL.

    Both are documented:

    http://docs.Oracle.com/CD/E11882_01/server.112/e10897/schema.htm#ADMQS0841

    Management of schema objects

  • Need help to identify the type of object in the loop of pl/sql

    Hello

    I need help to identify the Type of object declared beneath a procedure as shown below:

    I need to pass the parameter to the procedure as a TYPE of OBJECT and also refer to variables of Type Object in a loop

    create or replace type TEST_VALIDATION_REC is RECORD (order_num varchar2 (30),)

    number of inventory_item_id

    reserved_YN varchar2 (1).

    error_flag varchar2 (1).

    Error_message varchar2 (2000)

    );

    CREATE OR REPLACE TYPE VALD_TBL AS VARRAY (10000) OF TEST_VALIDATION_REC;

    PROCEDURE ADD_TO_ORD)

    p_lot_number_list IN VALD_TBL,

    p_ord_number IN Varchar2,

    p_user_id in NUMBER: = fnd_profile.value ('USER_ID'),-change 1.10

    p_responsibility_id in NUMBERS: = fnd_profile.value ('RESP_ID'),-change 1.10

    p_application_id IN VARCHAR2: = 'PO',-change 1.10

    x_error_flag OUT Varchar2,

    x_error_msg OUT Varchar2

    )

    In the above procedure, I had the VALD_TBL. Is it OK?

    And how in the loop if the records if I use:

    FOR indx1 IN 1.p_lot_number_list. COUNTY

    LOOP

    BEGIN

    SELECT

    inventory_item_id

    IN

    ln_item_id

    Of

    dummy_lot_tab

    WHERE

    lot_number = p_lot_number_list (indx1); - > how direct the item here?

    EXCEPTION

    WHILE OTHERS THEN

    ln_item_id: = NULL;

    END;

    Records are PL/SQL objects.  They are not the SQL objects.  You can create a SQL TYPE (schema level) as a collection (variable-tables only, tables nested).

    So therefore your first statement is syntactically incorrect

    CREATE OR REPLACE TYPE TEST_VALIDATION_REC IS RECORD
    (order_num VARCHAR2(30),
    inventory_item_id NUMBER,
    reserved_YN VARCHAR2(1),
    error_flag VARCHAR2(1),
    Error_message VARCHAR2(2000)
    );
    

    You must put in an anonymous PL/SQL block or the stored procedure

    DECLARE
    
       TYPE test_validation_rec IS RECORD
       (
        order_num VARCHAR2(30),
        inventory_item_id NUMBER,
        reserved_YN VARCHAR2(1),
        error_flag VARCHAR2(1),
        error_message VARCHAR2(2000)
       );
    
       TYPE vald_tbl iS VARRAY(10000) OF test_validation_rec;
    
       lv_tbl vald_tbl;
    
    BEGIN
    
       lv_tbl := vald_tbl();
      -- insert your code here 
    
    END;
    
  • How to change the type of object?

    I have an object type, as shown below:

    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;


    Now I want to change the type of object. I want to increase the size of val1 to varchar2 (100).

    Any body could help for the alter script.

    Thank you
    Lavan

    >
    SQL > alter type test_object1 change attribute (varchar2 (100)) val1;
    >
    Which won't work OPs example. Your example does not include the second type of object that depends on the first type.

    You cannot change the underlying type unless you use the CASCADe or INVALIDATE option.
    >
    change the type of test_object1 change attribute (val1 varchar2 (100)) waterfall;
    >
    See the CASCADE clause in the link provided by Osame
    >
    CASCADE clause

    Specify the CASCADE clause if you want to propagate the type change to the tables and dependent types. Oracle database abandons the statement if errors are found in the dependent types or tables, unless you also specify the FORCE.

    If you change the property of the type between FINAL and NON-FINAL, you must specify this clause to convert data in the tables and dependent columns. Please refer to [NOT] FINAL.

  • [CS2] [VB] How can I determine the type of object to a PageItem?

    I use InDesign CS2 and VBScript

    Loop to the bottom of the PageItems in a Page, I need determine the Type of object (TextFrame, group, GraphicLine... each process) and PageItem accordingly.

    Is there a method/function VBS wiil returns the Type of an object as a string or a value. Or what I need to check the existence/non-existence of a particular property associated with a particular object for this type?

    Alternatively, is there a JavaScript function that will do what I can call VBScript?

    For the record: TypeName is what you need.

    For example, when the cursor is planted in the text return TypeName (Ind.Selection (1)) 'PointInsertion.' When a text block is selected, it returns "TextFrame.

  • What is the difference between objects and units in coherence?

    What is the difference between objects and units in coherence?
    For example, < high-units >

    The units are the number of entries of data stored in the coherence of caches.
    The high-units element corresponds to the maximum number of 'units' (entered data, including units in order to backup, not even with objects) allowing to store in a particular JVM for a specific cache coherence. In addition, this number should be the same on all nodes (i.e. use the same cache on all nodes configuration file).
    The objects are the number of entries of data stored in cache coherence excluding the entries for other purposes (for example, backup).

    RE: To get Coherence to report object sizes you need to set the unit-caculator to binary.
    

    If you don caculator-unit set, consistency can use the default setting (set) to the report.

  • read the type of variable and the value of LabView

    With the help of the TS. Class sequence that I try to get the type of variable and the values of local variables, parameter, fileglobal and stationglobal. Unfortunately I'm not able to find the right function. Hope someone can help me.

    Kind regards

    Lars

    Hello

    Maybe this simple TestStand example will help you.

    The API calls for LabView are the same...

    Hope that helps

    Jürgen

  • Error: the registry settings used by the iTunes for importing and burning CDs and DVDs are missing.

    Original title: the registry settings used by the iTunes for importing and burning CDs and DVDs are missing. This can occur as a result of installing other CD burning software. reinstall iTunes

    I've loaded and discharged Itunes 5 times and still get the same error message box. This error does exactly what he says, I can not burn anything in my itunes library. ITunes worked great in XP-3 no problems. It will not work on Windows 7-64.  I can download and play songs from any site, but can not burn anything.  And I don't have any other burning software on my CD PC

    Hello PohlCat,

    Given that you have uninstalled and reinstalled iTunes without correcting the problem, it may be with a 3rd party product causes a problem.

    I would look at the post here to see if this solution can help you. It's from a 3rd third party site, you should use at your own risk, because it has not been tested, but seemed to help others with the same error that you are experiencing.

    Please reply back and let us know if this can help.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • Can I use other Adobe ID instead of the Adobe ID, used for the command to install and activate the Photoshop CS6?

    Can I use other Adobe ID instead of the Adobe ID, used for the command to install and activate the Photoshop CS6?

    Thank you

    Only ID authorized to use the software is the ID of the software license.

    Transfer an Adobe product license

  • Ask about the types of objects

    Hello

    I have a question about the type of object. I want to see the script for the type of object created, that is already stored in the database. How can I see who


    Concerning

    Hello

    So, you can try [DBMS_METADATA. GET_DDL | http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_metada.htm#ARPLS640]...

    MHO%xe> create or replace type mytype as object( col varchar2( 10 ));
      2  /
    
    Type is aangemaakt.
    
    Verstreken: 00:00:00.37
    MHO%xe> select dbms_metadata.get_ddl('TYPE', 'MYTYPE') from dual;
    
    DBMS_METADATA.GET_DDL('TYPE','MYTYPE')
    ------------------------------------------------------------------------------
    
      CREATE OR REPLACE TYPE "MHO"."MYTYPE" as object( col varchar2( 10 ));
    
  • Using the Type of object in fusion

    Hi all

    You have a small problem where I would like some suggestions.

    I had a declared TYPE.

    CREATE OR REPLACE TYPE 'MY_TYPE_OT' IS (OF THE OBJECT
    Field1 VARCHAR2,
    Field2 VARCHAR2,
    field3 VARCHAR2);

    I now have an array declared to type this

    TYPE MY_TYPE_TT IS TABLE OF INDEX MY_TYPE_OT BY VARCHAR2 (100);

    I have the collection of type MY_TYPE_TT

    MY_TYPE_TT MY_VARIABLE;

    I am populating this variable lets say 10 records.


    Then I try to save it to a database table, my_table for this I need to merge since it could be an update or insert. so, my query goes like this


    MERGE INTO my_table T2 using T1 ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2) TABLE ($my_var)

    Here, I get an error that my_variable is not a table. I tried different things like doing a casting, which gives me invalid data type etc.

    Any suggestions on how to pick up on this?

    Thanks in advance
    Paddy

    Collection with "index of" cannot be used in the context of sql. You can or use the collections without "index of" or treat it manually. See the example:

    drop table MY_TABLE purge
    /
    CREATE OR REPLACE TYPE MY_TYPE_OT IS OBJECT (
    field1 VARCHAR2(100),
    field2 VARCHAR2(100),
    field3 VARCHAR2(100))
    /
    create table MY_TABLE of MY_TYPE_OT
    /
    declare
      TYPE MY_TYPE_TT     IS TABLE OF MY_TYPE_OT INDEX BY VARCHAR2(100);
      MY_VAR              MY_TYPE_TT;
    begin
      --just testing values for collection:
      for i in 1..3
        loop
          MY_VAR(i):=MY_TYPE_OT(null,null,null);
          MY_VAR(i).field1:='field1-'||i;
          MY_VAR(i).field2:='field2-'||i;
          MY_VAR(i).field3:='field3-'||i;
        end loop;
    
      -- manually merging by one row:
      for c in MY_VAR.first..MY_VAR.last
        loop
          execute immediate '
            merge into MY_TABLE T2
            USING (select :1 field1, :2 field2, :3 field3 from dual) T1
            ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2)
            when matched then
              update set
                     t2.field3=t1.field3
            when not matched then
              insert values(t1.field1,t1.field2,t1.field3)
          '
          using MY_VAR(c).field1,MY_VAR(c).field2,MY_VAR(c).field3
        ;
        end loop;
    end;
    /
    

    Kind regards
    Malakshinov Sayan

  • What is the type of object to use for virtual machine model in the Points of Extension?

    Hello

    I added my plugin point of extension vsphere.core. ${objectType} .monitorViews. My plugin is for all types of objects (vm, file, vApp, resourcePool, etc) except the model of the virtual machine. My understanding is that the vm object type would be required for the virtual machine template, but that doesn't seem to be the case. Am I missing something here? Should the plugin appear for the model of the virtual machine when I use the vsphere.core.vm.monitorViews extension point?

    Thanks in advance.

    Kind regards

    Ashutosh

    Sorry, I got confused by your original question. ExtensionPoint id you are looking for is the one for adding views a model virtual machine monitor tab:

    model.monitorViews vSphere.Core.

  • problem with the type of local and global

    Hi the gems...

    I have a plsql package. In the package, I defined a proc that takes two input parameters of type simple number and a parameter of a type of output collection.

    create or replace package pack_1 as body
    procedure proc_1 (p_number1 in number, p_number2 number, p_tt_table to tt_table) as
    v_tt_table tt_table:=tt_table();
    type c_ref_cursor is ref_cursor;
    v_c_ref_cursor c_ref_cursor;
    v_sql varchar2 (20000): = < a large sql using bind variables p_number1 and p_number2 >

    Start
    Open the v_c_ref_cursor for v_sql using p_number1, p_number2;
    loop
    extract the v_c_ref_cursor in v_tt_table;
    When the output v_tt_table.count = 0;
    for idx in 1.v_tt_table.count
    loop
    < business logic >
    end of loop
    end loop;
    close v_c_ref_cursor;
    < excpetion_block >;
    end;

    < several codes for the rest of the package >



    When I execute the proc_1 then he throws me error of data type incosistent while to fetch the v_c_ref_cursor of cursor in the v_tt_table variable.
    ORA-00932: inconsistent data types: expected - was -.
    But I have checked that the output of the query is similar with the type of variable.

    Now, a few facts: the tt_table of the user-defined table type is made from ot_table (create or replace tt_table to ot_table Board).
    The parent type i.e. ot_table has the same columns of this query in v_sql my proc.
    The ot_table and the tt_table are global types.

    But when I did these two types as local types, then the proc works very well. But I need them as global types only according to the condition in java.

    Please help me. The database is 11 GR 2.

    Thanks in advance.

    user12780416 wrote:

    I'm trying to keep it in the simplest form... Please take a look...

    Ah... Easy to solve.

    The projection of SQL must be an object of type ot_test_type for extraction in bulk work.

    Your projection of SQL look like this:
    cursor c1 is select object_name from user_objects;

    object_name is a string - it is not of type ot_test_type.

    You must change the projection to return ot_test_type. This is done by using the default constructor for that type of object.

    For example
    cursor c1 is ot_test_type (object_name) select as the user_objects OBJECT;

    He may now be in bulk recovered in tt_test_type.

Maybe you are looking for