Using the collection as a Table

Hi,
I want to use a collection as a Table.Can anyone give me any code sample for that.
I am getting a collection through in parameter and want to join that rows with another table to out another collection.I want that because if I will do the operation in loop by taking the element one by one and comparing with the DB table record,the performance will be degraded.
Please give the solution for using a collection as a table to join it with another table.
Thanks in advance
Guljeet

Something like this probably will do for you.
SQL> create table t1 as
  2  select 1 col1 from dual union all
  3  select 2 from dual union all
  4  select 3 from dual;
Table created
SQL> create or replace type typ_row as object (col1 number, col2 varchar2(10));
  2  /
Type created
SQL> create or replace type typ_table as table of typ_row
  2  /
Type created
SQL> set serveroutput on
SQL>
SQL> declare
  2    tab_test typ_table := typ_table(typ_row(1, 'A'), typ_row(3, 'C'));
  3    cursor cur1 is
  4      select t1.col1, t2.col2
  5        from t1
  6        join table(tab_test) t2 on t1.col1 = t2.col1; --use table() and put your collection in it then join
  7  begin
  8    for rec in cur1 -- sample execution just for displaying the join performed
  9    loop
10      dbms_output.put_line(rec.col1 || ' ' || rec.col2);
11    end loop;
12  end;
13  /
1 A
3 C
PL/SQL procedure successfully completed
SQL> or, after creating the structures, simply run something like:
SQL> select t1.col1, t2.col2
  2        from t1
  3        join table(typ_table(typ_row(1, 'A'), typ_row(3, 'C'))) t2 on t1.col1 = t2.col1;
      COL1 COL2
         1 A
         3 C
SQL>

Similar Messages

  • How to use the TableSorter for two tables at the same view?

    Hello,
    I am using the TableSorter object in order to sort Dynpro tables.
    Suppose I have two tables at the same view, is it possible to use it seperatly for both of them?
    I assume that at the wdModifyView method I will need to catch the table that the user clicked on, yet I don't have an idea of how to do it...

    Hi Roy,
    Constructor of TableSorter
    public TableSorter(IWDTable table, IWDAction sortAction, Comparator[] comparators)
    So, you have to create instance of TableSorter class for each table on the view.
    best regards, Maksim Rashchynski.

  • How do I use the value of a table attribute outside the table?

    I have two tables that are master detail. But it might not be so obvious to the user before he knows how the page works that they are master detail. The tables are in separate showDetailItems in a panelAccordion and what I was thinking of was to show the value of one coloum in the selected row in the master in the text in the showdetail item that contains the detail table. But I can´t find the right expression to put into the accordion. How should the expression look like to get the value of an attribute in a table for use outside the table?

    Thanks for the suggestion but it doesn´t work. The first problem is that the page turns blank when I use that expression for the text in the showDetailItem and the second problem is that I don´t seem to be able to use the master table as a partial trigger. When I click edit in the partial trigger property I can´t shuttle the master table over to be a partial trigger to the showDetailItem even if the table has an id.
    Edited by: Atlantic Viking on Apr 2, 2009 6:24 AM
    Well I figured out how to come half way. I did the following things:
    1) Created an attribute value binding to the attribute I wanted to be shown in the showDetailItem
    2) Set the text property in the showDetailItem to this attribute value like this #{binding.attributeValue}
    To solve the problem I had with the partial triggers I continued like this
    3) Gave other components on the path from the showDetailItem to the master table id´s
    4) Clicked edit on the partial trigger property on the showDetailItem and was now able to shuttle the master table over to be a partial trigger.
    But I now got an other problem which looks like a bug. At first when I enter the page it looks fine but when I change focus in the master table to another row part of the showDetailItem containing the detail table disapears. The detail table still remains and works as it should but the part containing the text I tried to set above disapears and the text in the showDetailItem containing the master gets replaced by the text that was supposed to be in the showDetailItem containing the detail table. Any suggestions how to correct this are very welcome.
    Edited by: Atlantic Viking on Apr 2, 2009 6:59 AM

  • Ways to use the Content option in table sources

    how many ways we can use the (Logical table sources->Content tab).
    tell me in which situations we use the aggregation levels.are those only with detail tables?
    anybody explain me more elaborately?
    Edited by: user12077461 on Dec 31, 2010 6:16 AM

    In the content tab, you can configure in which (column or logical level) you want the aggregation to happen.
    For example you are dealing with sales, you can aggregate your results in the "sales per product level" or "sales per state level"
    In addition, you can also aggregate your results based on column summation.

  • How to improve performance using bulk collects with plsql tables or arrays

    Hi All,
    my procedure is like this
    declare
    cursor c1 is select ----------------------
    begin
    assigning to variables
    validations on that variables
    --50 validations are here --
    insert into a table
    end;
    we have created indexes on primary keys,
    i want to use
    DECLARE
    CURSOR a_cur IS
    SELECT program_id
    FROM airplanes;
    TYPE myarray IS TABLE OF a_cur%ROWTYPE;
    cur_array myarray;
    BEGIN
    OPEN a_cur;
    LOOP
    FETCH a_cur BULK COLLECT INTO cur_array LIMIT 100;
    ***---------can i assign cursor data to the plsql table variables or array***
    ***validate on the pl sql variable as---***
    i
    nsert into a table
    EXIT WHEN a_cur%NOTFOUND;
    END LOOP;
    CLOSE a_cur;
    END;
    Edited by: Veekay on Oct 21, 2011 4:28 AM

    Fastest way often is this:
    insert /*+append */
    into aTable
    select * from airplanes;
    commit;The select and insert part can even be done in parallel if needed.
    However if the oparation is complex or the dataset is very very very very very large or the programmer is decent but not excellent then the bulk approach should be considered. It is often a pretty stable and linear scaling approach.
    The solution depends a little on the database version.
    LOOP
      FETCH a_cur BULK COLLECT INTO cur_array LIMIT 100;
      EXIT WHEN a_cur.count = 0;
      forall i in a_cur.first.. a_cur.last
      insert into aTable (id)
      values (a_cur(i));
    END LOOP;
    ...If you have more then one column then you might need a single collection for each column. Other possibilities depend on the db version.
    Also: do not exit using a_cur%NOTFOUND. This is wrong! You might loose records from the end of the data set.

  • How to get the sum in BSEG table using select statement

    hai all
    i made the internal tale "itab1" .. i want to get the som  feild of  DMBTR in BSG table my code is here but its not working gave som error massage (Aggregate functions and the addition DISTINCT are not supported in field lists for pooled and cluster tables.)  plz tel me how should i do it..... i want to get the som of that feild....          
    loop at itab1
         SELECT sum( DMBTR  ) from bseg INTO itab1-DMBTR141_45
             where GJAHR = itab1-GJAHR
             and   BELNR = itab1-BELNR.
    endloop.
    regard
    nawa

    SELECT BELNR GJAHR SHKZG DMBTR
                 from bseg
                 INTO table it_bseg
                 for all entries in itab1
                 where GJAHR = itab1-GJAHR
                   and BELNR = itab1-BELNR.
    loop at it_bseg.
        IF it_bseg-shkzg = 'H'.
          it_bseg-dmbtr = it_bseg-dmbtr * ( -1 ).
        ELSE.
          it_bseg-dmbtr = it_bseg-dmbtr.
        ENDIF.
        MODIFY it_bseg.
    endloop.
    loop at it_bseg.
    READ TABLE itab1 with key belnr = it_bseg-belnr
                               gjahr = it_bseg-gjahr.
    if sy-subrc = 0.
    collect it_bseg into it_bseg_amount.
    endif.
    endloop.
    U can use the collect statement
    Regards
    Gopi

  • Problem getting the collection objects in Toplinks using JDeveloper11g

    Hi All
    I am working the Toplinks in JDeveloper11g. I am using the Java Objects From Tables to create the Toplink map .
    The problem is I am unable to work with the collection objects. I am getting the collection objects like addtocollection and removefromcollection. when I am dragging the collection object into the form and running the application it is giving errors.
    Can any one help me out how to work with this collection objects.
    Thanks in advance
    Madhavi.

    look at the java.util.SortedMap interface, and the classes that implement it. or, re-think your design. why do you want the entries sorted? do you really want that, or do you assume you do? is a Map the right collection here? I'm not saying it isn't, I'm just saying that the sorting requirement sounds like an assumption you need to challenge. generally, we get data out of a Map by explicitly asking for it by key

  • Determining the space used by data in a table at the granularity of bytes

    The SPACE_USAGE procedure of DBMS_SPACE package
    is meant for knowing space table with auto segment
    space management.
    It gives out 4 types of values fs1_blocks to
    fs4_blocks as the number of blocks which are filled
    25%, 50%, ....
    I tried it with different number of records (including)
    and empty table) but all 4 fields are always output as
    zero.
    Basically my aim is to know the actual amount of space
    used by my data in the table for both auto segment
    allocation and non auto mode.

    To have this kind of information I've used the function
    DBMS_SPACE.UNUSED_SPACE, that reporting:
    TOTAL_BLOCKS - data allocation space (in blocks)
    TOTAL_BYTES - data allocation space (in bytes)
    UNUSED_BLOCKS - allocated space but not used (in blocks)
    UNUSED_BYTES - allocated space but not used (in bytes)
    The difference between TOTAL_BYTES and UNUSED_BYTES is the REAL SIZE of your data.
    I don't know if you can use the same function for table with auto segment space management.
    Bye L.

  • How can we use the table partitions feature and.........

    Hai friends when i tried to use the bitmap indexes and table partitions feature ,
    I got a message like this
    'table partiotion feature not enabled'
    so please tell me how can i enable those features so that i will be able to use those features..........

    Partitioning and Bitmap Indexes are features of Oracle Enterprise addition. In fact, I think that Partitioning is an extra option that needs to purchased with Oracle Enterprise - it is not a default feature.
    These features do not exist on Oracle Standard Edition (and likely Express Edition too).

  • Issue with use of collection type attibutes of oracle custom objects in BC4

    Hi There,
    Just see the simulation, it seems to be an issue with BC4J/OC4j when we have an attribute in the view object mapped to a database column that is of type collection of custom oracle objects.
    1-     I have a oracle type Quantity that is defined to contain 2 numbers
    2-     I have a oracle collection QuantityList that is a collection of Quantity objects.
    3-     I have a table defined as :
    CREATE TABLE ANU_TEST_QUANTITYLIST
      ID        NUMBER,
      USR_DATA  QUANTITYLIST
    NESTED TABLE USR_DATA STORE AS ANU_QUANTITYLIST;4-     Now I try to select the id and usr_data column of this table through the VAnuTestQuantityList view.
    5-     It throws the following exception:
    ## Detail 0 ##
    java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)

    I try using the "Business components from tables" wizard to create a new EO, VO, and AM related to the ANU_TEST_QUANTITYLIST and it works fine for me. You'll see that JDeveloper creates you a custom Quantitylist domain object as part of this process.
    If you are making programmatic use of the oracle.sql.STRUCT then you will see this error in three-tier.
    Use the oracle.jbo.domain.Struct instead.

  • How to use BULK COLLECT in oracle forms

    hi gurus,
    I am using oracle forms
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionI wanna use bulk collect from database table lets say <employees>
    while working on database level with collections and records it's working very well for me, but when I try to use that technique on oracle forms it hits me error
    error 591 this feature is not supported in client side programmingI know I can use cursors to loop through the records of oracle tables ,
    but I'm convenient while using collections and arrays
    for example
    Set Serveroutput On
    Declare
          Type Rec_T Is Record (     
           Empid Number ,
           Empname Varchar2(100)
          Type V_R Is Table Of Rec_T Index By Binary_Integer;     
          V_Array V_R;
    Begin
       Select Employee_Id , First_Name
       Bulk Collect
       Into V_Array
          From Employees; 
       For Indx In V_Array.First..V_Array.Last Loop
       Dbms_Output.Put_Line('employees id '||V_Array(Indx).Empid ||'and the name is '||V_Array(Indx).Empname);
       End Loop;      
         End;I wanna use this same way on oracle forms , for certain purposes , please guide me how can I use ...
    thanks...

    For information, you can use and populate a collection within the Forms application without using the BULK COLLECT
    Francoisactually I want to work with arrays , index tables ,
    like
             record_type (variable , variable2);
             type type_name <record_type>  index by binary_integer
            type_variable type_name;
            and in main body of program
            select something
            bulk collect into type_variable
            from any_table;
           loop
                type_variable(indx).variable , type_variable(indx).variable2;
           end loop;
           this is very useful for my logic on which I am working
              like
              type_variable(indx).variable || type_variable(indx-1);
             if it's possible with cursors then how can I use cursor that can fullfill my this logic@Francois
    if it's possible then how can i populate without using bulk collect?
    thanks
    and for others replies: if I can use stored procedures please give me any example..
    thanks

  • Calling Stored procedure which uses Bulk Collect

    Hi All, I have Oracle stored procedure which uses Bulk Collect and returns table type parameter as output. Can anyone please help me how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. (I am successfully able to call using MS ODBC driver, but I want to use OraOLEDB driver.)

    861412 wrote:
    how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. This forum deals with the server-side languages SQL and PL/SQL.
    Your question deals with the client side and Visual Basic language.

  • ORA-06502 during a procedure which uses Bulk collect feature and nested tab

    Hello Friends,
    have created one procedure which uses Bulk collect and nested table to hold the bulk data. This procedure was using one cursor and a nested table with the same type as the cursor to hold data fetched from cursor. Bulk collection technique was used to collect data from cursor to nested table. But it is giving ORA-06502 error.
    I reduced code of procedure to following to trace the error point. But still error is comming. Please help us to find the cause and solve it.
    Script which is giving error:
    declare
    v_Errorflag BINARY_INTEGER;
    v_flag number := 1;
    CURSOR cur_terminal_info Is
    SELECT distinct
    'a' SettlementType
    FROM
    dual;
    TYPE typ_cur_terminal IS TABLE OF cur_terminal_info%ROWTYPE;
    Tab_Terminal_info typ_cur_Terminal;
    BEGIN
    v_Errorflag := 2;
    OPEN cur_terminal_info;
    LOOP
    v_Errorflag := 4;
    FETCH cur_terminal_info BULK COLLECT INTO tab_terminal_info LIMIT 300;
    EXIT WHEN cur_terminal_info%rowcount &lt;= 0;
    v_Errorflag := 5;
    FOR Y IN Tab_Terminal_Info.FIRST..tab_terminal_info.LAST
    LOOP
    dbms_output.put_line(v_flag);
    v_flag := v_flag + 1;
    end loop;
    END LOOP;
    v_Errorflag := 13;
    COMMIT;
    END;
    I have updated script as following to change datatype as varchar2 for nested table, but still same error is
    comming..
    declare
    v_Errorflag BINARY_INTEGER;
    v_flag number := 1;
    CURSOR cur_terminal_info Is
    SELECT distinct
    'a' SettlementType
    FROM
    dual;
    TYPE typ_cur_terminal IS TABLE OF varchar2(50);
    Tab_Terminal_info typ_cur_Terminal;
    BEGIN
    v_Errorflag := 2;
    OPEN cur_terminal_info;
    LOOP
    v_Errorflag := 4;
    FETCH cur_terminal_info BULK COLLECT INTO tab_terminal_info LIMIT 300;
    EXIT WHEN cur_terminal_info%rowcount &lt;= 0;
    v_Errorflag := 5;
    FOR Y IN Tab_Terminal_Info.FIRST..tab_terminal_info.LAST
    LOOP
    dbms_output.put_line(v_flag);
    v_flag := v_flag + 1;
    end loop;
    END LOOP;
    v_Errorflag := 13;
    COMMIT;
    I could not find the exact reason of error.
    Please help us to solve this error.
    Thanks and Regards..
    Dipali..

    Hello Friends,
    I got the solution.. :)
    I did one mistake in procedure where the loop should end.
    I used the statemetn: EXIT WHEN cur_terminal_info%rowcount &lt;= 0;
    But it should be: EXIT WHEN Tab_Terminal_Info.COUNT &lt;= 0;
    Now my script is working fine.. :)
    Thanks and Regards,
    Dipali..

  • How to choose the partition in oracle tables?

    Dear all,
    i m in need to create the partitions on prod.db tables since i m not aware of creating partitions?i just go through some theroy concepts and understood the range and list partitions (i.e)Range is normally used for values less than like jan,feb,march or values less than 50,000 values less than 1,00,000 like that each partition is having separate tablespaces to increase the performance. and for list is used to denoting the directions like west,east,north,south like that.
    Now what i want to know is ?
    1.)when will i can go ahead with partitions?
    2.)before creating partitions is it advise to create index or not needed?
    3.)if i started to create partition what is the leading column have to create partition and which partition has to choose?
    pls let me know and pardon me if i did any mistakes.
    thanks in advance..

    I had to research on same topic. One of my teammates suggested few points that might help you also.
    Advantages of partitioning:
    1) Partitioning enables data management operations such data loads, index creation and rebuilding, and backup/recovery at the partition level, rather than on the entire table. This results in significantly reduced times for these operations.
    2) Partitioning improves query performance. In some cases, the results of a query can be achieved by accessing a subset of partitions, rather than the entire table. Parallel queries/DML and Partition-wise Joins are also got benefited much.
    3) Partitioning increases the availability of mission-critical databases if critical tables and indexes are divided into partitions to reduce the maintenance windows, recovery times, and impact of failures. (Each partition can have separate physical attributes such as pctfree, pctused, and tablespaces.)
    Partitioning can be implemented without requiring any modifications to your applications. For example, you could convert a nonpartitioned table to a partitioned table without needing to modify any of the SELECT statements or DML statements which access that table. You do not need to rewrite your application code to take advantage of partitioning.
    Disadvantages of partitioning:-
    1) Advantages of partition nullified when you use bind variables.
    Additional administration tasks to manage partitions viz. If situation arises for rebuilding of index then rebuilding should to be done for each individual partition.
    2) Need more space to implement partitioning objects.
    3) More time for some tasks, such as create non-partitioning indexes, collection of “global" statistics (dbms_stat’s granularity parameter to be set to GLOBAL. if sub partition are used then we have to set it to ALL).
    4) Partition would implies a modification (of explain plan) for ALL the queries against the partitioned tables. So, if some queries use the choosing partition key and may greatly improve, some other queries not use the partition key and are dramatically bad impact by the partitioning.
    5) To get the full advantage of partitioning (partition pruning, partition-wise joins, and so on), you must use the Cost Based Optimizer (CBO). If you use the RBO, and a table in the query is partitioned, Oracle kicks in the CBO while optimizing it. But because the statistics are not present, the CBO makes up the statistics, and this could lead to severely expensive optimization plans and extremely poor performance.
    Message was edited by:
    Abou

  • Using the Document Manager Rich Text Editor

    I'm wondering whether there is a reasonable way we can use the Rich Text Editor (based on CKEditor) that is contained within the Document Manager task flow (primarily for editing Wiki pages) outside of the Document Manager itself? We have another type of content we need a Rich Text Editor for, but it would be great if we could use the inline image links, tables, links to documents in the content repository, etc.

    Have you consider use Site Studio + Content Presenter?
    http://docs.oracle.com/cd/E17904_01/webcenter.1111/e10149/content_cp.htm
    http://george.maggessy.com/2012/05/inline-editing-in-content-presenter-for_10.html
    []'s

Maybe you are looking for

  • How do I update ios in an older touch?

    I have a 2nd gen 8gb touch that I want to upgrade to a more recent ios. I'll be brief. How? I can't seem to find anything that even tells me what version is installed. Thanks in advance. Doc

  • How to acess headphone-​jack

    I have a Dv9843cl, and for some reason the input jack from some speakers broke so they are stuck in the headphone slot and i can't get it out, can someone help me?

  • Xmltype data can't be copied from remote database

    Hi, I got the following same error when copy table with xmltype from different env: table localXML(xml xmltype); insert into localXML select * from remoteXML@romote; 1. run from db tools: ... Physical database connection acquired for: local 12:07:41

  • Is the power bar still available

    Is the power bar still available l have ee broadband and ee tv but l havent got mobile phone with ee  

  • Icon turned red after update to 12.0.1.26

    My iTunes icon on my desktop turned red after I updated to 12.0.1.26. Does that mean something is wrong with my iTunes? It has never been red before.