How to get the desire output from sql query

Consider an Order Table: ...
Order Table:
Order Id Item Qty
O1 A1 5
O2 A2 1
O3 A3 3
Please provide SQL which will explode the above data into single unit level records as shown below
Desired Output:
Order Id Order Id Qty
O1 A1 1
O1 A1 1
O1 A1 1
O1 A1 1
O1 A1 1
O2 A2 1
O3 A3 1
O3 A3 1
O3 A3 1

How do I ask a question on the forums?
SQL and PL/SQL FAQ

Similar Messages

  • How to get the desired output in the format ...?

    Hi all,
    I am having data like this.
    Col1 col2 col3
    1 2 1
    1 2 2
    1 2 3
    2 3 7
    2 3 8
    2 3 9
    I want to output the data like this
    1 2 1,2,3
    2 3 7,8,9
    How to get this.
    Thanks in advance,
    Pal

    In simple sql...
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from t
      2  /
          COL1       COL2       COL3
             1          2          1
             1          2          2
             1          2          3
             2          3          7
             2          3          8
             2          3          9
    6 rows selected.
    SQL> select max(decode(rno,1,to_number(col1||col2||col3))) col1, max(decode(rno,2,col3)) col2, max(decode(rno,3,col3)) col3
      2    from (select row_number() over(partition by col1,col2 order by col3) rno, t.*
      3           from t)
      4  group by col1
      5  /
          COL1       COL2       COL3
           121          2          3
           237          8          9
    SQL>Thanks,
    Karthick.

  • How to get the desired output

    My Table Data
    ContractID     MaterialGroup      CommodityCode     Amount
    C123       Travel     200     100
    C123      Travel     201     100
    C123             Travel     203     100
    C124            Stationery     315     500
    C126            Travel             200     600
    C126            Admin             413     600
    My expected output
    ContractID     MaterialGroup      CommodityCode     Amount
    C123        Travel             200|201|203     100
    C124             Stationery             315                     500
    C126            Travel|Admin     200|413           600
    My Present Output
    CONTRACTID MATERIALGROUP    COMMODITYCODE AMOUNT
    C123            Travel|Travel|Travel  200|203|201        100
    C124            Stationery               315                     500
    C126            Travel|Admin           200|413               600
    My Query:
      SELECT ContractID,
      RTrim(
                  xmlagg(
                          xmlelement(e, MaterialGroup|| '|')).extract('//text()'),'|') MaterialGroup,
      RTrim(
                  xmlagg(
                          xmlelement(e, CommodityCode|| '|')).extract('//text()'),'|') CommodityCode,Amount
    FROM (
    WITH t1 AS (
    SELECT 'C123' ContractID,     'Travel'MaterialGroup,      200     CommodityCode, 100 Amount FROM dual UNION all
    SELECT 'C123',            'Travel',     201,     100 FROM dual UNION all
    SELECT 'C123',            'Travel',     203,     100 FROM dual UNION all
    SELECT 'C124','Stationery',     315,     500 FROM dual UNION all
    SELECT 'C126','Travel',     200,     600 FROM dual UNION all
    SELECT 'C126','Admin',413,     600 FROM dual)
    SELECT * FROM t1)
    GROUP BY ContractID,Amount;

    select t.*,
            case when cdm = 1 and cm > 1
                    then substr(materialgroup,1, instr(materialgroup,'|', cdm)-1)
                    else materialgroup end materialgroup_edit,
             case when cdm = 1 and cm > 1 then mm else materialgroup end materialgroup_edit2
    from
              select contractid,
              count(materialgroup) cm,
              count(distinct materialgroup) cdm,
              max(materialgroup) mm,
              rtrim(
                          xmlagg(
                                  xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
            from (
            with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  )
            select * from t1)
            group by contractid,amount
            ) t;
    CONTRACTID         CM        CDM MM         MATERIALGROUP        COMMODITYCODE            AMOUNT MATERIALGROUP_EDIT   MATERIALGROUP_EDIT2
    C123                3          1 Travel     Travel|Travel|Travel 200|203|201                 100 Travel               Travel             
    C124                1          1 Stationery Stationery           315                         500 Stationery           Stationery         
    C126                2          2 Travel     Travel|Admin         200|413                     600 Travel|Admin         Travel|Admin       
    3 rows selected.
    select contractid,
              case when count(distinct materialgroup) = 1 and count(materialgroup) > 1 then max(materialgroup)
              else
              rtrim(
                          xmlagg(
                                  xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') end materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
            from (
            with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  )
            select * from t1)
            group by contractid,amount;
    CONTRACTID MATERIALGROUP        COMMODITYCODE            AMOUNT
    C123       Travel               200|203|201                 100
    C124       Stationery           315                         500
    C126       Travel|Admin         200|413                     600
    3 rows selected.
    with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  ),
            t2 as
            select contractid, materialgroup
            from t1
            group by contractid, materialgroup
    select  t1.contractid,
              t2.materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
    from t1,
                    select contractid,
                                rtrim(
                                      xmlagg(
                                              xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup
                    from t2
                    group by contractid
                    ) t2
    where t1.contractid = t2.contractid
    group by t1.contractid, t2.materialgroup, t1.amount;
    CONTRACTID MATERIALGROUP        COMMODITYCODE            AMOUNT
    C123       Travel               200|203|201                 100
    C124       Stationery           315                         500
    C126       Admin|Travel         200|413                     600
    3 rows selected.

  • How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    Hi,
    Thanks for the suggestion. I've been playing around with some of the classes of the java.net package and java.io
    Using the URL class i can get the content of the data from a STATIC page and output that response to file so that is does not display to the client broswer.
    But this only works if the URL i give points to a static html page.
    So the problem i'm getting is if i'm righting in arguments in the URL, this means that server needs to process the arguments i give and its sends back a dynamic result. Because its dynamic the URL class can not handle this and throws me an exception everytime :(
    Have u ever tried to do some things like this?
    Rahul

  • How to get the Database type from weblogic Db connection

    I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
    What my question is how to get the database type from the connection.

    For a normal jdbc driver you can use
    Connection.getMetaData()
    To get the meta data, in particular the getDatabase...() methods.
    That might or might not work.
    However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out.

  • How to get the return values from a web page

    Hi all :
       how to get the return values from a web page ?  I mean how pass values betwen webflow and web page ?
    thank you very much
    Edited by: jingying Sony on Apr 15, 2010 6:15 AM
    Edited by: jingying Sony on Apr 15, 2010 6:18 AM

    Hi,
    What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
    Regards,
    Karri

  • How to get the current week from sysdate?

    Hi sir,
    i want to know how to get the current week from sysdate?
    thanks

    Hi Nicolas
    It seems you like to check my post and also make commend ;) thanks for your attention
    Have you ever read the posts above and given solutions ?Yes, I did
    Have you read the docs ? Yes, I checked
    What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
    => Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
    So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
    Hope my answer could satisfy you..
    One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
    I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
    Thank you
    Regards
    Helios

  • How to get the selection parameters from logical database into one of the t

    Hi Sap ABAP Champians,
    How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
    Please help me for this
    Thanks
    Basu

    Hi
    Thanks, that will work, but then I'll have to insert code into all my reports.
    I can see that "Application Server Control Console" is able to rerun a report.
    This must mean that the Report Server has access to the runtime parameters.
    But how?
    Cheers
    Nils Peter

  • How to get the date starting from 1 to the current date from the system dat

    Dear all,
    Please tell me how to get the date starting from 1 based on the system date
    and it should come with respect of time also.
    example.
    suppose today is 6 Dec, 2006
    so ABAP report should find the 1 dec. 2006.
    Please help me as soon as possible.
    Regards,

    concatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
    or yo ucan use the fm:
    HR_JP_MONTH_BEGIN_END_DATE
    usage:
        call function 'HR_JP_MONTH_BEGIN_END_DATE'
             exporting
                  iv_date             = sy-datum
             importing
                  ev_month_begin_date = gv_begda
                  ev_month_end_date   = gv_endda.
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • How to get the XML messages from JMS Queue in BPM

    I have one requirement in my application.we are sending XML messages to the JMS Queue.How to get the XML messages from JMS Queue and how to Extract the details from XMl.
    can you please send me the code to get the XML messages from the JMS Queue.
    Thank you,

    Hi,
    Sure others will have some other ideas, but here's what I typically do to get the XML from a JMS queue. Inside the Global Automatic that pops the messages off the queue you'd have logic similar to this:
    artifactInfoNodes as Any[]
    xmlObject as Fuego.Xml.XMLObject = XMLObject()
    load xmlObject using xmlText = message.textValue
    . . . Once you have this, it's a matter of deciding what you want to do with the message. Most times you'll parse the XML (using XPATH statemens), set argument variables and create a work item instance.
    Hope this helps,
    Dan

  • Get the record count from a query

    Hi,
    does anyone know how to get the record count from a sql query?
    e.g: I've got a ResultSet from the Statement.excuteQuery(), and I want to know how many records this ResultSet contains, how to get this?
    I'd read thoughout the documents of Statement and ResultSet, but couldn't find a solution, do I have to use another seperate query such as "select count(*)" to do this?
    thanks.
    Yang Liu

    If you are not using a scrollable result set then the following is the best way to do it.
    there are several key words in SQL that can be used, the one you are interested in is count();
    so if your query at the moment is
    "select col1, col2, col3 from my_table where col2=? and col3=?"you can work out how many rows will be returned by executing this command first
    "select count(col1) from my_table where col2=? and col3=?"this will return a result set with one row and one column, you can get the row count as follows:
    ResultSet rs = ps.executeQuery();
    int rowCount = rs.getInt(1);I hope this helps :)

  • How to correctly perform a join to get the desired output

    Hi,
    I have the following query which gives me the desired output.
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    left outer join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    The output of the above query will be like this
    3646 2014-04-17 Store OPS GOAL 2598.00000
    3646 2014-04-16 Store OPS GOAL 2475.00000
    3646 2014-04-15 Store OPS GOAL 2497.00000
    3646 2014-04-14 Store OPS GOAL 2691.00000
    But the problem with this query is it brings back the OPS Goal for all the dates,but i have to limit the OPS goals to some particular date range which must match to this table Staging.TEDW_S_EMPOWER.So,I made the above query join to this table like this
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    left outer join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    left outer join
    Staging.TEDW_S_EMPOWER
    on TEDW_D_DATE_TYPE_1.DATE_SHORT = TEDW_S_EMPOWER.DATE_SHORT
    and TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_S_EMPOWER.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    having TEDW_D_DATE_TYPE_1.DATE_SHORT between MIN(TEDW_S_EMPOWER.date_short) and MAX(TEDW_S_EMPOWER.date_short)
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    Now the output of this query will be like this
    3646 2014-04-17 Store OPS GOAL 7794.00000
    3646 2014-04-16 Store OPS GOAL 7425.00000
    3646 2014-04-15 Store OPS GOAL 7491.00000
    3646 2014-04-14 Store OPS GOAL 8073.00000
    If you can observe the OPS Goal Sum values have changed drastically, i was able to limit the date range i wanted but now i dont get the correct OPS Goal values.
    Can someone please help me with this?
    Thanks

    Hi RJP,
    Yes you are absolutely correct, in the "Staging.TEDW_S_EMPOWER"
    we have 3 rows for every date and location,so i changed my second sql to be something like this
    SELECT
    Cast(TEDW_F_STORE_OPS_GOAL.LOCATION_NUM As Varchar) As LOCATION_NUM,
    Cast(TEDW_D_DATE_TYPE_1.DATE_SHORT As Varchar) As DATE_SHORT,
    'Store' As DRIVER_TYPE,
    'OPS GOAL' As DRIVER,
    SUM(OPS_GOAL) /3 As ROW_TOTAL
    FROM Planning.TEDW_F_STORE_OPS_GOAL
    cross join
    EDW.Utility.TEDW_J_PROCESS_DATE
    inner join
    edw.Calendar.TEDW_D_DATE_TYPE_1
    ON TEDW_F_STORE_OPS_GOAL.DATE_KEY = TEDW_D_DATE_TYPE_1.DATE_KEY
    left outer join
    [EDW].[Location].[TEDW_D_LOCATION_TYPE_1_NEW]
    ON TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_NUM
    left outer join
    Staging.TEDW_S_EMPOWER
    on TEDW_D_DATE_TYPE_1.DATE_SHORT = TEDW_S_EMPOWER.DATE_SHORT
    and TEDW_F_STORE_OPS_GOAL.LOCATION_NUM = TEDW_S_EMPOWER.LOCATION_NUM
    where TEDW_D_LOCATION_TYPE_1_NEW.LOCATION_TYPE_DESC = 'FULL PRICE STORE'
    group by
    TEDW_F_STORE_OPS_GOAL.LOCATION_NUM,
    TEDW_D_DATE_TYPE_1.DATE_SHORT
    having TEDW_D_DATE_TYPE_1.DATE_SHORT between MIN(TEDW_S_EMPOWER.date_short) and MAX(TEDW_S_EMPOWER.date_short)
    order by LOCATION_NUM desc
    , DATE_SHORT desc
    Now i receive the correct values as i am doing divided
    by 3,but may be in the future the empower tablemay have more than 3 ,is there any other effective way i can do this?
    below is the sample query and sample data from empower table.
    select * from Staging.TEDW_S_EMPOWER
    where DATE_SHORT = '2014-04-17'
    and LOCATION_NUM = 3020
    DRIVER_TYPE DRIVER DATE_SHORT
    store Sales 2014-04-17
    store Transactions 2014-04-17
    store Traffic 2014-04-17
    Thanks

  • How can I get the data array from SQL Server Database?

    Hi,
    I can write a data array(2D)into a table of my SQL Server Database. The data array was writen to a column with image type. I know a data array is transformed a binary string when writing into database, but I dont know how to get the data array when I fetch the binary string from database.
    My question is:
    How to transform the binary string into data array? which vi's should I use? I have tried unflatten from string but failed.
    Any response is appriciated.
    Red

    happyxh0518 wrote:
    > I can write a data array(2D)into a table of my SQL Server Database.
    > The data array was writen to a column with image type. I know a data
    > array is transformed a binary string when writing into database, but I
    > dont know how to get the data array when I fetch the binary string
    > from database.
    >
    > My question is:
    > How to transform the binary string into data array? which vi's should
    > I use? I have tried unflatten from string but failed.
    In order to use Unflatten from string you first need to Flatten it
    before writing it. Also depending on the database driver, the returned
    data may actually not be binary but Hexadecimal encoded ASCII which you
    would first have to decode to binray.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to get the SSO user from PL/SQL with Windows native authen

    I connect to a 10g daabase using SSO through Windows Native Authentication wher the OID user mapps to a single Database user.
    I need to get the SSO user from pl/sql
    My fornt end is Portal & Forms

    Hmm, I see.
    Well your problem boils down to being in the database and needing to have access to web environment variables. The SSO sets specific variables in the environment but your stored procedure is not privy to them.
    Now having said that, note that the mod_plsql Web Toolkit has a utility for accessing cgi variables. For instance,
    owa_util.get_cgi_env('Osso-User-Dn')
    If your web application cannot capture the SSO info and pass it to the stored proc in a parameter, OWA may be the only way.
    Check out the Single Sign-On Developers Guide, specifically the part about developing statically protected PLSQL applications.
    Hope this helps.
    regards,
    tt

  • How to get the selected values from a selectmanylistbox?

    Hi ADF Experts,
    <af:selectManyListbox label="Label 1" id="sml1" partialTriggers="cb2"
                            value="#{viewScope.TestBean.lovValue}"
                      autoSubmit="true"      valuePassThru="true">
        <f:selectItems value="#{viewScope.TestBean.actualList}" id="si1"
                       binding="#{viewScope.TestBean.selectedItems}"/>
      </af:selectManyListbox>
      <af:commandButton text="get selected values" id="cb3"
                        actionListener="#{viewScope.TestBean.getSelectedValues}"
                        partialSubmit="true"/>
      private List<String> lovValue;
      private List<SelectItem> actualList;
    //getters and setters
      public void getSelectedValues(ActionEvent actionEvent) {
        // Add event code here...
        for (String selectedItem : lovValue) {
            System.out.println("Selected item: " +selectedItem.); // this is giving 1 and 3 like this. how to get the checked values as I'm getting only the indexes. In this scenario I am populating the list programmatically.Just I wanted to know how can we get the selected values(not indexes). Please suggest.
    Thanks-
    Abhijit

    Hi Timo,
    As I am sharing the page fragment and the Java class. So its my usecase I have mentioned below
    I am sharing the jsff page fragment and java class. So that it wud be of help to others.
    jsff page fragment
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core">
            <af:panelGroupLayout id="pgl1">
              <af:commandButton text="Search"  id="cb1"
                                actionListener="#{viewScope.TestBean.searchSupplier}"/>
    </af:panelGroupLayout>
        <af:popup id="p1" binding="#{viewScope.TestBean.searchSupplierPopup}">
              <af:dialog id="d2"
                         type="none">
               <af:table value="#{bindings.Contacts.collectionModel}" var="row"
                      rows="#{bindings.Contacts.rangeSize}"
                      emptyText="#{bindings.Contacts.viewable ? 'No data to display.' : 'Access Denied.'}"
                      fetchSize="#{bindings.Contacts.rangeSize}"
                      rowBandingInterval="0"
                      binding="#{viewScope.TestBean.tsupportIssues}"
                      filterModel="#{bindings.ContactsQuery.queryDescriptor}"
                      queryListener="#{bindings.ContactsQuery.processQuery}"
                      filterVisible="true" varStatus="vs"
                      selectionListener="#{bindings.Contacts.collectionModel.makeCurrent}"
                      rowSelection="multiple" id="t1">
              <af:column sortProperty="name" filterable="true" sortable="true"
                         headerText="#{bindings.Contacts.hints.name.label}" id="c2">
                <af:outputText value="#{row.name}" id="ot1"/>
              </af:column>
              <af:column sortProperty="email" filterable="true" sortable="true"
                         headerText="#{bindings.Contacts.hints.email.label}"
                         id="c1">
                <af:outputText value="#{row.email}" id="ot2"/>
              </af:column>
            </af:table>
          <af:commandButton text="OK" id="cb5" partialSubmit="true"       actionListener="#{viewScope.TestBean.testMethod}"/>
          <af:commandButton text="Cancel" id="cb6"
                            actionListener="#{viewScope.TestBean.cancelPopupSearch}"/>
        </af:dialog>
            </af:popup>
      <af:selectManyListbox label="Label 1" id="sml1" partialTriggers="cb5"
                            value="#{viewScope.TestBean.lovValue}"
                      autoSubmit="true"      valuePassThru="true"
                            binding="#{viewScope.TestBean.prp1}">
        <f:selectItems value="#{viewScope.TestBean.actualList}" id="si1"
                       binding="#{viewScope.TestBean.selectedItems}"/>
      </af:selectManyListbox>
      <af:commandButton text="get selected values" id="cb3"
                        actionListener="#{viewScope.TestBean.getSelectedValues}"
                        partialSubmit="true"/>
      <af:commandButton text="remove selected" id="cb4"
             partialSubmit="true"           actionListener="#{viewScope.TestBean.removeSelectedValues}"/>
    </jsp:root>
    TestBean.java
    package com.demo.view;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.faces.component.UISelectItems;
    import javax.faces.event.ActionEvent;
    import javax.faces.model.SelectItem;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.rich.component.rich.RichPopup;
    import oracle.adf.view.rich.component.rich.data.RichTable;
    import oracle.adf.view.rich.component.rich.input.RichSelectManyListbox;
    import oracle.adf.view.rich.context.AdfFacesContext;
    import oracle.adf.view.rich.event.DialogEvent;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowSetIterator;
    import org.apache.myfaces.trinidad.model.RowKeySet;
    public class TestBean {
      private RichTable tsupportIssues;
      private List<SelectItem> lovValue;
      private List<SelectItem> actualList;
      private RichSelectManyListbox prp1;
      private List valuesChoosed = new ArrayList();
      private UISelectItems selectedItems;
      private RichPopup searchSupplierPopup;
        public TestBean() {
        super();
      public void setTsupportIssues(RichTable tsupportIssues) {
        this.tsupportIssues = tsupportIssues;
      public RichTable getTsupportIssues() {
        return tsupportIssues;
      public void testMethod(ActionEvent actionEvent) {
        // Add event code here...
        // For learning purposes - show Select Many Button clicked 
         System.out.println("Select Many Button has been Clicked");
        // // RowKeySet Object can hold the selected rows from a user as follows    
        RowKeySet rksSelectedRows =         this.getTsupportIssues().getSelectedRowKeys();
        // Iterator object provides the ability to use hasNext(), next() and remove() against the selected rows 
        Iterator itrSelectedRows = rksSelectedRows.iterator();  
        // Get the data control that is bound to the table - e.g.
        // OpenSupportItemsIterator    
        DCBindingContainer bindings =         (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); 
        DCIteratorBinding dcIteratorBindings =         bindings.findIteratorBinding("findAllContactsIterator"); 
        // Information from binding that is specific to the rows  
        RowSetIterator rsiSelectedRows =         dcIteratorBindings.getRowSetIterator();   
        // Loop through selected rows  
        int i=1;
        while (itrSelectedRows.hasNext()) {        
          // Get key for selected row    
          Key key = (Key)((List)itrSelectedRows.next()).get(0);  
          // Use the key to get the data from the above binding that is related to the row      
          Row myRow = rsiSelectedRows.getRow(key);         
          // Display attribute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces       
          System.out.println(myRow.getAttribute("name"));
          valuesChoosed.add(myRow.getAttribute("name"));
    //        actualList = new ArrayList<SelectItem>();
    //        String j = Integer.toString(i);
    //        actualList.add(new SelectItem(j, (String)myRow.getAttribute("name")));
    //      i++;
           searchSupplierPopup.hide();
          AdfFacesContext.getCurrentInstance().addPartialTarget(prp1);
      public void setLovValue(List<SelectItem> lovValue) {
        this.lovValue = lovValue;
      public List<SelectItem> getLovValue() {
        return lovValue;
      public void setActualList(List<SelectItem> actualList) {
        this.actualList = actualList;
      public List<SelectItem> getActualList() {
        actualList = new ArrayList<SelectItem>();
        if(valuesChoosed.size()!=0){
        for(int i=0;i<valuesChoosed.size();i++){
          actualList.add(new SelectItem(valuesChoosed.get(i), (String)valuesChoosed.get(i)));
        else{
          actualList.add(new SelectItem("1","Select One"));
        return actualList;
      public void setPrp1(RichSelectManyListbox prp1) {
        this.prp1 = prp1;
      public RichSelectManyListbox getPrp1() {
        return prp1;
      public void setValuesChoosed(List valuesChoosed) {
        this.valuesChoosed = valuesChoosed;
      public List getValuesChoosed() {
        return valuesChoosed;
      public void getValues(ActionEvent actionEvent) {
        // Add event code here...
        for(int i=0;i<valuesChoosed.size();i++){
          System.out.println(valuesChoosed.get(i));
      public void getSelectedValues(ActionEvent actionEvent) {
        // Add event code here...
         for(int i=0;i<this.getLovValue().size();i++){
             System.out.println("Selected Value:"+this.getLovValue().get(i));
      public void removeSelectedValues(ActionEvent actionEvent) {
        // Add event code here...
      public void setSelectedItems(UISelectItems selectedItems) {
        this.selectedItems = selectedItems;
      public UISelectItems getSelectedItems() {
        return selectedItems;
        public void setSearchSupplierPopup(RichPopup searchSupplierPopup) {
            this.searchSupplierPopup = searchSupplierPopup;
        public RichPopup getSearchSupplierPopup() {
            return searchSupplierPopup;
        public void cancelPopupSearch(ActionEvent actionEvent) {
            // Add event code here...
            searchSupplierPopup.hide();
        public void searchSupplier(ActionEvent actionEvent) {
            // Add event code here...
            RichPopup.PopupHints hints = new RichPopup.PopupHints();
            searchSupplierPopup.show(hints);
    package com.demo.view;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.faces.component.UISelectItems;
    import javax.faces.event.ActionEvent;
    import javax.faces.model.SelectItem;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.rich.component.rich.RichPopup;
    import oracle.adf.view.rich.component.rich.data.RichTable;
    import oracle.adf.view.rich.component.rich.input.RichSelectManyListbox;
    import oracle.adf.view.rich.context.AdfFacesContext;
    import oracle.adf.view.rich.event.DialogEvent;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowSetIterator;
    import org.apache.myfaces.trinidad.model.RowKeySet;
    public class TestBean {
      private RichTable tsupportIssues;
      private List<SelectItem> lovValue;
      private List<SelectItem> actualList;
      private RichSelectManyListbox prp1;
      private List valuesChoosed = new ArrayList();
      private UISelectItems selectedItems;
      private RichPopup searchSupplierPopup;
        public TestBean() {
        super();
      public void setTsupportIssues(RichTable tsupportIssues) {
        this.tsupportIssues = tsupportIssues;
      public RichTable getTsupportIssues() {
        return tsupportIssues;
      public void testMethod(ActionEvent actionEvent) {
        // Add event code here...
        // For learning purposes - show Select Many Button clicked 
         System.out.println("Select Many Button has been Clicked");
        // // RowKeySet Object can hold the selected rows from a user as follows    
        RowKeySet rksSelectedRows =         this.getTsupportIssues().getSelectedRowKeys();
        // Iterator object provides the ability to use hasNext(), next() and remove() against the selected rows 
        Iterator itrSelectedRows = rksSelectedRows.iterator();  
        // Get the data control that is bound to the table - e.g.
        // OpenSupportItemsIterator    
        DCBindingContainer bindings =         (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); 
        DCIteratorBinding dcIteratorBindings =         bindings.findIteratorBinding("findAllContactsIterator"); 
        // Information from binding that is specific to the rows  
        RowSetIterator rsiSelectedRows =         dcIteratorBindings.getRowSetIterator();   
        // Loop through selected rows  
        int i=1;
        while (itrSelectedRows.hasNext()) {        
          // Get key for selected row    
          Key key = (Key)((List)itrSelectedRows.next()).get(0);  
          // Use the key to get the data from the above binding that is related to the row      
          Row myRow = rsiSelectedRows.getRow(key);         
          // Display attribute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces       
          System.out.println(myRow.getAttribute("name"));
          valuesChoosed.add(myRow.getAttribute("name"));
    //        actualList = new ArrayList<SelectItem>();
    //        String j = Integer.toString(i);
    //        actualList.add(new SelectItem(j, (String)myRow.getAttribute("name")));
    //      i++;
           searchSupplierPopup.hide();
          AdfFacesContext.getCurrentInstance().addPartialTarget(prp1);
      public void setLovValue(List<SelectItem> lovValue) {
        this.lovValue = lovValue;
      public List<SelectItem> getLovValue() {
        return lovValue;
      public void setActualList(List<SelectItem> actualList) {
        this.actualList = actualList;
      public List<SelectItem> getActualList() {
        actualList = new ArrayList<SelectItem>();
        if(valuesChoosed.size()!=0){
        for(int i=0;i<valuesChoosed.size();i++){
          actualList.add(new SelectItem(valuesChoosed.get(i), (String)valuesChoosed.get(i)));
        else{
          actualList.add(new SelectItem("1","Select One"));
        return actualList;
      public void setPrp1(RichSelectManyListbox prp1) {
        this.prp1 = prp1;
      public RichSelectManyListbox getPrp1() {
        return prp1;
      public void setValuesChoosed(List valuesChoosed) {
        this.valuesChoosed = valuesChoosed;
      public List getValuesChoosed() {
        return valuesChoosed;
      public void getValues(ActionEvent actionEvent) {
        // Add event code here...
        for(int i=0;i<valuesChoosed.size();i++){
          System.out.println(valuesChoosed.get(i));
      public void getSelectedValues(ActionEvent actionEvent) {
        // Add event code here...
         for(int i=0;i<this.getLovValue().size();i++){
             System.out.println("Selected Value:"+this.getLovValue().get(i));
      public void removeSelectedValues(ActionEvent actionEvent) {
        // Add event code here...
        for(int i=0;i<this.getLovValue().size();i++){
            System.out.println("Selected Value:"+this.getLovValue().get(i));
            System.out.println(this.getLovValue().remove(i));
          AdfFacesContext.getCurrentInstance().addPartialTarget(prp1);
      public void setSelectedItems(UISelectItems selectedItems) {
        this.selectedItems = selectedItems;
      public UISelectItems getSelectedItems() {
        return selectedItems;
        public void setSearchSupplierPopup(RichPopup searchSupplierPopup) {
            this.searchSupplierPopup = searchSupplierPopup;
        public RichPopup getSearchSupplierPopup() {
            return searchSupplierPopup;
        public void cancelPopupSearch(ActionEvent actionEvent) {
            // Add event code here...
            searchSupplierPopup.hide();
        public void searchSupplier(ActionEvent actionEvent) {
            // Add event code here...
            RichPopup.PopupHints hints = new RichPopup.PopupHints();
            searchSupplierPopup.show(hints);
    Thanks,
    A. Abhijit

Maybe you are looking for