Select or deselect multiple rows with one single selection  event

Does anyone know how to create a JTable which can select or deselect multiple rows with one single selection event in JTable. Fore example, if the table has
row1
row2
row3
row4
row5
row6
What I need is when user select row1 or row2, both row1 and row2 should be set to be selected. Then if user press CTRL and click one of row3 or row4, both of them should be selected including the previouse selected row1 and row2.
For deselection, if row1 and row2 are selected, when users deselect one of row1 or row2, both of them should be deselected.
Hopefully someone can give me a hint.

Here is a partial solution using a JList. Only one line gets highlighted when the user makes a selection in the list. But, two lines are returned. There is a blank line between every two lines.
     private void addLineToList() {
          String a = f_one.getText();
          String b = f_two.getText();
          if (a.length() == 0) {
               Utils.showInformationMessage("Item field is empty.");
               f_one.requestFocusInWindow();
               return;
          if (b.length() == 0) {
               Utils.showInformationMessage("Match field is empty.");
               f_two.requestFocusInWindow();
               return;
          model.addElement("item: " + a);
          model.addElement("match: " + b);
          model.addElement(" ");
          int size = model.getSize();
          pairList.setSelectedIndex(size - 3);
          f_one.setText("");
          f_two.setText("");
          f_one.requestFocusInWindow();
     private void editList() {
          if (pairList.getSelectedValue().toString().equalsIgnoreCase(" ")) {
               Toolkit.getDefaultToolkit().beep();
               f_one.requestFocusInWindow();
               return;
          if (!f_one.getText().equals("")) {
               int result = JOptionPane.showConfirmDialog(this,
               "The Item field contains text. Replace the text?",
               "Flash Card Activity", JOptionPane.YES_NO_OPTION,
               OptionPane.INFORMATION_MESSAGE);
               if (result == JOptionPane.NO_OPTION) return;
          if (!f_two.getText().equals("")) {
               int result = JOptionPane.showConfirmDialog(this,
               "The Match field contains text. Replace the text?",
               "Flash Card Activity", JOptionPane.YES_NO_OPTION,
               JOptionPane.INFORMATION_MESSAGE);
               if (result == JOptionPane.NO_OPTION) return;
          String item = "";
          String match = "";
          int index = pairList.getSelectedIndex();
          String choice = model.getElementAt(index).toString();
          if (choice.startsWith("item")) {
               item = choice;
               match = model.getElementAt(index + 1).toString();
               model.remove(index);
               model.remove(index);
               model.remove(index);
          else {
               item = model.getElementAt(index - 1).toString();
               match = choice;
               model.remove(index + 1);
               model.remove(index);
               model.remove(index - 1);
          int size = model.getSize();
          if (size > 2) {
               pairList.setSelectedIndex(size - 2);
          f_one.setText(item.substring(6));
          f_two.setText(match.substring(7));
          f_one.requestFocusInWindow();
     }

Similar Messages

  • Multiple Domains with one single Portal

    We have installed Oracle Infrastructure and Oracle Midtier on one box. Let's say the domain name is http://www.abc.com. When we query http://www.abc.com, it
    goes to the SSO (Infra) and validates the username and password and takes it back to the Mid-Tier Portal Pages. At this junction, everything is working as expected.
    Now, we created two more webpages and they correspond to two domains -- let's say http://www.pqr.com and http://www.xyz.com. The two webpages that got created were PUBLIC pages, so anybody can have access to those pages.
    Can we implement our requirements using one infrastructure and one midtier (1st)installation? OR do we install two more midtier (2nd, 3rd) to correspond
    to each domain name which are www.pqr.com and www.xyz.com and then have the proxy server redirect the request for www.abc.com to 1st-Midtier, www.pqr.com
    to 2nd-Midtier and www.xyz.com to 3rd-Midtier?
    We have a apache proxy server installed in front of the 9iAS, but we are going to use it just for redirection.
    I understand Oracle Infrastructure has only ONE portal Schema and so how would multiple midtier (webpages) will reside? Do I need to create another PORTAL repository and a new DAD, so that www.pqr.com points to the 2nd-Portal Repository and www.xyz.com points to the 3rd-portal?

    Through a single mid-tier it is possible to configure Oracle HTTP Server/Web Cache such that they are configured to handle multiple logical site names (e.g. www.pqr.com and www.xyz.com) by using Virtual Hosts.
    In terms of a single Portal Repository being accessed by multiple mid-tiers (or logical sites), this is not currently possible since the Portal Repository is configured with only one set of site details.
    For further information on configuring Virtual Hosts and Portal see the Advanced Chapter of the 10g Portal configuration guide...
    http://download-west.oracle.com/docs/cd/B10464_01/portal.904/b10356/cg_advnc.htm#1040267

  • Insert multiple rows with one sql statement in access

    Hi,
    I'm trying to copy a table into another. What I want to do is to use "Insert into table1 select * from table2 where field > val". Something like that. I know a lot of databases support it. I was wondering if ms access ODBC driver also supports it. I searched quite a bit and haven't found a definitive answer on this.
    Thank you

    Yes, M$ Access 2000 supports it. This is from their help:
    INSERT INTO Statement
    Adds a record or multiple records to a table. This is referred to as an append query.
    Syntax
    Multiple-record append query:
    INSERT INTO target [(field1[, field2[, ...]])] [IN externaldatabase]
    SELECT [source.]field1[, field2[, ...]
    FROM tableexpression
    Single-record append query:
    INSERT INTO target [(field1[, field2[, ...]])]
    VALUES (value1[, value2[, ...])
    The way you've written the INSERT, table1 and table2 have to have the same # of columns and the same types, of course.

  • Transform multiple rows to one single xml

    Hi!
    How to get only one xml (10gR2)?
    I found this example:
    set long 32000
    SELECT XMLELEMENT("EMP_TABLE",
    (select XMLELEMENT("EMP_ROW",
    XMLFOREST(empno, ename, job, mgr, hiredate, sal, deptno)
    from emp
    where empno = 7369))
    from dual;
    XMLELEMENT("EMP_TABLE",(SELECTXMLELEMENT("EMP_ROW",XMLFOREST(EMPNO,ENAME,JOB,MGR
    <EMP_TABLE><EMP_ROW><EMPNO>7369</EMPNO><ENAME>SMITH</ENAME><JOB>CLERK</JOB><MGR>
    7902</MGR><HIREDATE>1980-12-17</HIREDATE><SAL>800</SAL><DEPTNO>20</DEPTNO></EMP_
    ROW></EMP_TABLE>
    But what if I need a result without
    "where empno = 7369" e.g. all rows?
    Greetings
    Bjørn

    SQL> set long 32000
    SQL> set pagesize 0
    SQL> SELECT XMLELEMENT(
      2            "EMP_TABLE",
      3      (select xmlagg(xmlelement("EMP_ROW",
      4                (xmlforest(empno  as "empno"
      5                          ,ename  as "ename"
      6                          ,job    as "job"
      7                          ,mgr    as "mgr"
      8                          ,sal    as "sal"
      9                          ,deptno as "deptno")))) from emp)).extract('/').GetClobVal()
    10  from dual
    11  /
    <EMP_TABLE>                                                                    
      <EMP_ROW>                                                                    
        <empno>7521</empno>                                                        
        <ename>WARD</ename>                                                        
        <job>SALESMAN</job>                                                        
        <mgr>7698</mgr>                                                            
        <sal>1251.25</sal>                                                         
        <deptno>30</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7566</empno>                                                        
        <ename>JONES</ename>                                                       
        <job>MANAGER</job>                                                         
        <mgr>7839</mgr>                                                            
        <sal>2977.98</sal>                                                         
        <deptno>20</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7654</empno>                                                        
        <ename>MARTIN</ename>                                                      
        <job>SALESMAN</job>                                                        
        <mgr>7698</mgr>                                                            
        <sal>1251.25</sal>                                                         
        <deptno>30</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7698</empno>
        <ename>BLAKE</ename>                                                       
        <job>MANAGER</job>                                                         
        <mgr>7839</mgr>                                                            
        <sal>2852.85</sal>                                                         
        <deptno>30</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7788</empno>                                                        
        <ename>SCOTT</ename>                                                       
        <job>ANALYST</job>                                                         
        <mgr>7566</mgr>                                                            
        <sal>3003</sal>                                                            
        <deptno>20</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7839</empno>                                                        
        <ename>KING</ename>                                                        
        <job>PRESIDENT</job>                                                       
        <sal>5005</sal>                                                            
        <deptno>10</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7844</empno>                                                        
        <ename>TURNER</ename>                                                      
        <job>SALESMAN</job>                                                        
        <mgr>7698</mgr>                                                            
        <sal>1501.5</sal>                                                          
        <deptno>30</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7876</empno>                                                        
        <ename>ADAMS</ename>                                                       
        <job>CLERK</job>                                                           
        <mgr>7788</mgr>                                                            
        <sal>1101.1</sal>                                                          
        <deptno>20</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7900</empno>                                                        
        <ename>JAMES</ename>                                                       
        <job>CLERK</job>                                                           
        <mgr>7698</mgr>                                                            
        <sal>950.95</sal>                                                          
        <deptno>30</deptno>                                                        
      </EMP_ROW>                                                                   
      <EMP_ROW>                                                                    
        <empno>7934</empno>                                                        
        <ename>MILLER</ename>                                                      
        <job>CLERK</job>                                                           
        <mgr>7782</mgr>                                                            
        <sal>1301.3</sal>                                                          
        <deptno>10</deptno>                                                        
      </EMP_ROW>                                                                   
    </EMP_TABLE>                                                                   
    SQL>
    SQL> spool off

  • Create multiple folders with one click on documents tab in BP in SAP CRM

    Hi Experts,
    I have a requirement to create multiple folders by clicking on a button in Documents tab in BP transaction in CRM. In standard process by clicking on create folder button we create folders. we want to create multiple folders with one single click ( i guess we can develop another button for that) folder name will be hard coded. Kindly let me know , how this can be achieved.

    Hi Experts,
    I have a requirement to create multiple folders by clicking on a button in Documents tab in BP transaction in CRM. In standard process by clicking on create folder button we create folders. we want to create multiple folders with one single click ( i guess we can develop another button for that) folder name will be hard coded. Kindly let me know , how this can be achieved.

  • How to use Mulitple DAQs with a single triggered event on only one of the DAQs

    I have three PXI6115 and would like to tie all these to a single triggered event on one of the DAQs. I've scaned the examples and any assistance would be greatly appreciated....

    TCjr,
    Please refer to your other post:
    How to use Multiple DAQs with a single triggered event on only one of the DAQs

  • Multiple rows with single date

    I am using a CDC control task to extract and load data from our OLTP source to our Data Warehouse.
    For our Date dimension, we have a DateKey which is a
    DATETIME stamp (created using SSAS dimension wizard). Time is always 00:00:00 as a DATETIME
    value is required for populating the dates.
    Our fact table destination uses this DateKey as a FK.
    Our fact table OLTP data source contains multiple records with a single DATE and TIME field. This fine as I can convert the DATE field to a DATETIME using a derived column.
    However, as our Date dimension has granularity of a day, all we require for our fact table is the most recent daily record from our OLTP data source.
    At present, the data flow task is attempting to write all records and failing on PK constraint.
    How would I go about traversing all records for each date and loading only the most recent for that day? Is there a better way to go about this?

    If you wish to get only one record for today, you can simply use in your source query:
    SELECT TOP 1 ... FROM OLTPdata ORDER BY DEATETIMEcolumn DESC
    if you need one record for each date, you may use ranking functions:
    WITH Q AS (
    SELECT
    ROW_NUMBER() OVER (PARTITION BY CAST(DateTimeColumn AS DATE) ORDER BY DateTimeColumn DESC, some tie breaker column) AS ROWNUM,
    FROM  OLTPData
    SELECT * FROM Q WHERE ROWNUM=1

  • Multiple selections to multiple layers or multiple files with one go ?

    Hi,
    how to convert multiple selections to multiple layers or multiple files with one go ?
    Thanks!

    You may want to ask over at
    http://forums.adobe.com/community/photoshop/photoshop_scripting?view=discussions
    or
    http://ps-scripts.com/bb/
    I think there are Scripts about for the task or at least ones that could be adapted without too much problems.
    The usual approach is, I think, creating a Work Path from a Selection and then using (expanded) Selections based on the individual subPathItems to intersect with the original selection.
    Of course there are possibilities for bad results …

  • How do I insert multiple rows from a single form ...

    How do I insert multiple rows from a single form?
    This form is organised by a table. (just as in an excel format)
    I have 20 items on a form each row item has five field
    +++++++++++ FORM AREA+++++++++++++++++++++++++++++++++++++++++++++++++++++
    +Product| qty In | Qty Out | Balance | Date +
    +------------------------------------------------------------------------+
    +Item1 | textbox1 | textbox2 | textbox3 | date +
    + |value = $qty_in1|value= &qty_out1|value=$balance1|value=$date1 +
    +------------------------------------------------------------------------+
    +Item 2 | textbox1 | textbox2 | textbox4 | date +
    + |value = $qty_in2|value= $qty_out1|value=$balance2|value=$date2 +
    +------------------------------------------------------------------------+
    + Item3 | textbox1 | textbox2 | textbox3 | date +
    +------------------------------------------------------------------------+
    + contd | | | +
    +------------------------------------------------------------------------+
    + item20| | | | +
    +------------------------------------------------------------------------+
    + + + SUBMIT + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Database Structure
    +++++++++++++++++
    + Stock_tabe +
    +---------------+
    + refid +
    +---------------+
    + item +
    +---------------+
    + Qty In +
    +---------------+
    + Qty Out +
    +---------------+
    + Balance +
    +---------------+
    + Date +
    +++++++++++++++++
    Let's say for example user have to the use the form to enter all 10 items or few like 5 on their stock form into 4 different textbox field each lines of your form, however these items go into a "Stock_table" under Single insert transaction query when submit button is pressed.
    Please anyone help me out, on how to get this concept started.

    Hello,
    I have a way to do this, but it would take some hand coding on your part. If you feel comfortable hand writing php code and doing manual database calls, specificaly database INSERT calls you should be fine.
    Create a custom form using the ADDT Custom Form Wizard that has all the rows and fields you need. This may take a bit if you are adding the ability for up to 20 rows, as per your diagram of the form area. The nice thing about using ADDT to create the form is that you can setup the form validation at the same time. Leave the last step in the Custom Form Wizard blank. You can add a custom database call here, but I would leave it blank.
    Next, under ADDT's Forms Server Behaviors, select Custom Trigger. At the Basic tab, you enter your custom php code that will be executed. Here you are going to want to put your code that will check if a value has been entered in the form and then do a database INSERT operation on the Stock_table with that row. The advanced tab lets you set the order of operations and the name of the Custom Trigger. By default, it is set to AFTER. This means that the Custom Trigger will get executed AFTER the form data is processed by the Custom Form Transaction.
    I usually just enter TEST into the "Basic" tab of the Custom Trigger. Then set my order of operations in the "Advanced" tab and close the Custom Trigger. Then I go to the code view for that page in Dreamweaver and find the Custom Trigger function and edit the code manually. It's much easier this way because the Custom Trigger wizard does not show you formatting on the code, and you don't have to keep opening the Wizard to edit and test your code.
    Your going to have to have the Custom Trigger fuction do a test on the submitted form data. If data is present, then INSERT into database. Here's a basic example of what you need to do:
    In your code view, the Custom Trigger will look something like this:
    function Trigger_Custom(&$tNG) {
    if($tNG->getColumnValue("Item_1")) {
    $item1 = $tNG->getColumnValue("Item_1");
    $textbox1_1 = $tNG->getColumnValue("Textbox_1");
    $textbox1_2 = $tNG->getColumnValue("Textbox_2");
    $textbox1_3 = $tNG->getColumnValue("Textbox_3");
    $date1 = $tNG->getColumnValue("Textbox_3");
    $queryAdd = "INSERT INTO Stock_table
    (item, Qty_In, Qty_Out, Balance, Date) VALUES($item1, $textbox1_1, $textbox1_2, $textbox1_3, $date1)"
    $result = mysql_query($queryAdd) or die(mysql_error());
    This code checks to see if the form input field named Item_1 is set. If so, then get the rest of the values for the first item and insert them into the database. You would need to do this for each row in your form. So the if you let the customer add 20 rows, you would need to check 20 times to see if the data is there or write the code so that it stops once it encounters an empty Item field. To exit a Custom Trigger, you can return NULL; and it will jump out of the function. You can also throw custom error message out of triggers, but this post is already way to long to get into that.
    $tNG->getColumnValue("Item_1") is used to retrieve the value that was set by the form input field named Item_1. This field is named by the Custom Form Wizard when you create your form. You can see what all the input filed names are by looking in the code view for something like:
    // Add columns
    $customTransaction->addColumn("Item_1", "STRING_TYPE", "POST", "Item_1");
    There will be one for each field you created with the Custom Form Wizard.
    Unfortunately, I don't have an easy way to do what you need. Maybe there is a way, but since none of the experts have responded, I thought I would point you in a direction. You should read all you can about Custom Triggers in the ADDT documentation/help pdf to give you more detailed information about how Custom Triggers work.
    Hope this helps.
    Shane

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • I wanted to display the multiple rows in one row but column should be diff

    Hi
    Could any body help me regarding this query how to write to get the multiple rows in one row.
    eg.
    i have one table tab1(eno number,ename varchar2,uid1 varchar2,uid2 varchar2,uid3 varchar4)
    but when i am runing the query I am getting multiple record against one eno number because of uid1,uid2,uid3
    suppose value of table is
    eno ename uid1 uid2 uid3
    1 a u1
    1 a u2
    1 a u3
    when i am quering it is coming same as above but I want in one row
    eno ename uid1 uid2 uid3
    1 a u1 u2 u3
    can any onle help me how to write the query for this requirement.
    thanks
    saif

    which is hard coded in my code? Here another approach, but fail for c as there is no information for the value of a column: does 1 in u1 means col 1, etc.
    /* Formatted on 2012/05/29 16:29 (Formatter Plus v4.8.8) */
    WITH t AS
         (SELECT 1 col1, 'a' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'a' col2, 'u2' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'a' col2, 'u3' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u3' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u2' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'c' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'c' col2, 'u3' col3
            FROM DUAL)
    SELECT   xx.col1, xx.col2, MAX (DECODE (xx.rn, 1, col3)) AS uid1, MAX (DECODE (xx.rn, 2, col3)) AS uid2,
             MAX (DECODE (xx.rn, 3, col3)) AS uid3
        FROM (SELECT t.col1, t.col2, t.col3, ROW_NUMBER () OVER (PARTITION BY col1, col2 ORDER BY col3) rn
                FROM t) xx
    GROUP BY col1, col2;output:
    COL1     COL2     UID1     UID2     UID3
    1     a     u1     u2     u3
    1     b     u1     u2     u3
    1     c     u1     u3
    Edited by: ʃʃp on May 29, 2012 2:30 AM

  • Web dynpro screen with multiple rows with columns that can be edited

    Web dynpro screen with multiple rows with columns that can be edited individually:
    Hi
    I am busy creating a screen in web dynpro for ABAP which we would like to make available via Portal ESS (Portal 7).
    I need to add 'n type of table (or almost something like Excel) or something in which someone can type a few paycode numbers (there should be lets say 10 blank rows in which info can be typed in and if I click on a button or so, more rows must be added if necessary.  Then in the other colums stuff like amounts must be entered which one should also be able to edit then and there.
    Can anyone assist in what I can use for this?  There does not seem to be some existing element that I can use.
    Help will be appreciated.
    Regards
    Debbie

    Hi Debbie,
    Whiel Creating table you need to be care full that use chose INPUT FIELD as the CELL EDITOR. Just guessing that if ur table is not editable u might have choosen TextView as default cell editor type.
    check link for details on TABLE UI
    [http://help.sap.com/saphelp_erp2005/helpdata/EN/b5/ac884118aa1709e10000000a155106/frameset.htm]
    easy way is to first add UI ELEMENT TABLE to your VIEW, then right click over it & select create binding from context. After you have a pop up where you can select what columns you want what should be its cell editor etc.
    Greetings
    Prashant

  • Inserting multiple rows using a single Insert statement without using dual

    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;

    NiranjanSe wrote:
    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;
    SQL> create table ps_hd_samp (num1 number,num2 number);
    Table created.
    SQL> insert all
      2  into ps_hd_samp (num1,num2) values (1,1)
      3  into ps_hd_samp (num1,num2) values (2,2)
      4  into ps_hd_samp (num1,num2) values (3,3)
      5  select count(*)
      6  from ps_hd_samp;
    3 rows created.
    SQL> select * from ps_hd_samp;
          NUM1       NUM2
             1          1
             2          2
             3          3

  • Generating multiple rows from one physical row

    I was wondering if anyone has done or knows how to generate multiple rows for one physical row. In my query "SELECT Cust_No, Amount from Balances" if the amount is > 99,999.99 I want 2 rows returned, one with an amount of 90,000.00 and the other with an amount of 9,999.99. I'm thinking I need to use a view or function to return a result set but I'm not sure how.
    Thanks in advance,
    Allen Davis
    [email protected]

    James,
    Well your right in that you need a function, but also 3 views to accomplish that. I just wrote up the sql below and tested it. Basically you want the first view to return all records less than your cap of 99,999, thoes that exceed that will always return as 90,000 (see example on record PK 774177177). The second view returns money that remains AFTER the cap (in your case 9,999). The second view though also has to excude the ones less than the CAP.
    DATA and TABLE layout
    1) Table is called T1, columns are PK : primary key value, and N2 : some number column holding the MONEY amount
    2) data is below fromtable called t1 (10 records) ...
    select pk,n2 from t1 order by pk
    PK     N2
    117165529     100
    274000876     200000
    350682010     9999
    737652242     90000
    774177177     99999
    1369893126     1000
    1663704428     100000
    1720465556     8888
    1793125955     0
    1972069382     1000000
    Now see the records with money at 99,999 (just like in your example). You want 2 records, so the VIEWS now come into play. The view itself CALLS the function, this occurs when you select from the view. The function will either return 90,000 (your defined cap) or the remained after subtracting the money from 90,000. The 3 views are defined below (the FUNCTION which is shown after will have to be compiled first) ...
    --[VIEWS START]
    CREATE OR REPLACE VIEW VIEW1
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,1) FROM T1;
    CREATE OR REPLACE VIEW VIEW2
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,2) FROM T1 WHERE N2 >= 99999;
    CREATE OR REPLACE VIEW VIEW_ALL
    (PK,SHOW_MONEY)
    AS
    SELECT * FROM VIEW1
    UNION ALL
    SELECT * FROM VIEW2;
    --[VIEWS END]
    OK now for the actual function ...
    --[FUNCTION START]
    CREATE OR REPLACE FUNCTION
    FN_TRIM_MONEY
    PI_MONEY NUMBER,
    PI_VIEW_ID NUMBER
    RETURN NUMBER AS
    LS_TEMP VARCHAR2(2000);
    LI_TEMP NUMBER;
    LD_TEMP DATE;
    LI_CON_MONEY_MAX CONSTANT NUMBER := 90000;
    LS_RETURN VARCHAR2(2000);
    BEGIN
    IF (PI_MONEY > LI_CON_MONEY_MAX) THEN
    IF PI_VIEW_ID = 1 THEN
    LI_TEMP := LI_CON_MONEY_MAX;
    ELSIF PI_VIEW_ID = 2 THEN
    LI_TEMP := (PI_MONEY - LI_CON_MONEY_MAX);
    END IF;
    ELSE
    LI_TEMP := PI_MONEY;
    END IF;
    IF LI_TEMP < 0 THEN
    LI_TEMP := 0;
    END IF;
    LS_RETURN := LI_TEMP;
    RETURN LS_RETURN;
    END;
    SHOW ERRORS;
    --[FUNCTION END]
    I compiled the function and views with no errors. This is what I get when I query the 3 views ...
    --[VIEW 1]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    350682010     9999
    737652242     90000
    774177177     90000
    1369893126     1000
    1663704428     90000
    1720465556     8888
    1793125955     0
    1972069382     90000
    --[VIEW 2]
    PK     SHOW_MONEY
    274000876     110000
    774177177     9999
    1663704428     10000
    1972069382     910000
    --[VIEW ALL]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    274000876     110000
    350682010     9999
    737652242     90000
    774177177     90000
    774177177     9999
    1369893126     1000
    1663704428     90000
    1663704428     10000
    1720465556     8888
    1793125955     0
    1972069382     90000
    1972069382     910000
    So notice the PK entry 774177177 listed twice, once with 90,000 and other with 9,999. Also notice we now have 14 records from the original 10, meaning 4 records qualified for the split (all data from VIEW 2).
    This is why Oracle kicks ass, views and functions are very powerful when used together and can return pretty much anything.
    Thanks,
    Tyler D.
    [email protected]

  • Multiple row as a single row in a column

    Hi,
    I want to select Multiple rows into a single line in 'Single Column Table' .
    For ex:
    Employee table has only one column , named as empname . it has three rows
    Select empname from emp;
    empname
    thambi
    peter
    antony
    My expected result: thambi,peter,antony

    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002

Maybe you are looking for