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]

Similar Messages

  • Passing Multiple table row from one view to another view

    Hi,
    How to Passing Multiple table row from one view to another view in Web Dynpro Abap. (Table UI Element)
    thanx....

    Hi Ganesh,
    Kindly do search before posting.. this discussed many times..
    First create your context in component controller, and do context mapping in two views so that you can get values from
    one veiw to any views.
    and for multiple selection, for table we have property selection mode.. set as multi and remember context node selection
    selection cardinality shoud be 0-n.
    so, select n no of rows and based on some action call sec view and display data.( i think you know navigation between veiw ).
    Pelase check this...for multi selection
    Re: How to copy data from one node to another or fromone table to another table
    for navigation.. check
    navigation between the views
    Cheers,
    Kris.

  • Passing Multiple rows from one external webpart list to another

    Hi Folks,
                    I have almost spent 1 week looking into this without any success. I have an external list "List A"  (in a webpart) with one of the columns as "State".
    Another external list "List B"  (in a webpart ) has state and user as columns. In some case I want to pass 1 state and in another I want to pass multiple state.  Passing one state from List A to List B works fine. But Multiple state does
    not work because the webpart list has the property "Send First row to connected web parts when page loads".  If I disable this option then the web part does not pass anything. Is there a way to pass multiple rows from one Webpart
    external list to other?

    http://www.sharepointanalysthq.com/2010/07/bcs-external-list-limitations/
    No Lookups
    Unfortunatly the only thing that you can do a look up on in an external list is on the ID column, anything else and you are out of luck.
    http://social.technet.microsoft.com/Forums/en-US/615771a0-ba78-4e38-9e2d-ded0204173ba/external-list-referenced-as-sharepoint-lookup?forum=sharepointgeneralprevious
    Try below webpart. it should help
    http://www.sparqube.com/SharePoint-Lookup-Column/
    If this helped you resolve your issue, please mark it Answered

  • Reporting out multiple lookup rows for one fact row. NON-Aggregating

    Hi,
    I have a situation where I have multiple Look Up rows for one fact row. I want to report them out so that I get One row with the Look Up and Fact information in it and the next row with Just the Look Up information in it.
    The version of Oracle I'm using is 9.2.0.6.0.
    Look Up Table
    Deal Order Number     Partial Order ID     INVENTORY_ITEM_ID     MANUFACTURER_DESCRIPTION
    639416-1                1                     43601                     Check Point
    639416-1                1                     98809                      Nokia
    637260-1                 1                     56657                   IBM
    637260-1                 1                     35467                   QuantumFact Table
    Deal Order Number     Partial Order ID     Cost
    639416-1                 1                     3825.3
    637260-1                  1                   3610.8Desired result:
    Deal Order Number     Partial Order ID     MANUFACTURER_DESCRIPTION     Cost
    639416-1                    1                        Check Point            3825.3
    639416-1                     1                         Nokia
    637260-1                     1                         Ibm                   3610.8
    637260-1                     1                         QuantumBasically I'd like the ability to report out every row of my report with the first row containing the Fact Data and then the following rows containing the Look Up data that are also associated with that fact column but not report the data.
    I'm doing this because there's Grand totaling at the bottom of the report that I don't want to mess with.
    Plus instead of concatenating the Look Up values together, I need to show them in their own cells in their own rows for view ability.
    I think an Analytic function might take care of this but I'm not sure how. Can anyone help?
    Thanks in Advance!

    Hi,
    Join the two tables as you normally would.
    You're right about analytic functions being useful. The anaylytic ROW_NUMBER function can number each row of the join, with a separate count for each unique id from lookup.
    Use a CASE statement to display certain items from fact when ROW_NUMBER retuns 1, and hide them otherwise.
    SELECT     f.order_number
    ,     f.partial_order_number
    ,     l.manufacturer_description
    ,     CASE
              WHEN     ROW_NUMBER () OVER
                        ( PARTITION BY     f.order_number
                          ,          f.partial_order_number
                          ORDER BY     l.manufacturer_description
                        ) = 1
              THEN     cost
         END     AS cost_col
    FROM     fact     f
    JOIN     lookup     l     ON     f.order_number          = l.order_number
                   AND     f.partial_order_number     = l.partial_order_number
    ORDER BY     f.order_number
    ,          f.partial_order_number
    ,          l.manufacturer_description
    ;

  • Copying table rows from one table to another table form

    Hi
    I have a problem about Copying table rows from one table to another table form.On jsf pages if you enter command button go anather jsf page and it copy one row to another table row. But when i execute this process for table FORM it doesn't copy I wrote a code under "createRowFromResultSet - overridden for custom java data source support." Code block is:
    ViewRowImpl value = super.createRowFromResultSet(qc, resultSet);
    try{
    AdfFacesContext fct = AdfFacesContext.getCurrentInstance();
    Number abc = (Number)fct.getProcessScope().get("___");
    value.setAttribute("___",abc);
    }catch(Exception ex){System.out.println(ex);  }
    return value;

    Table may be copied with the
    expdp and impdp utilities.
    http://www.oracle.com/technology/products/database/utilities/index.html

  • HOW TO GET THE SELECTED VALUE IN A ROW FROM ONE VIEW TO ANOTHER VIEW?

    hi all,
    I  have a small issue.
    i have created two views.In the table of the first view i'm selecting a row and pressing the button it will move to next view.
    i am adding some fields manually in the table of the second view and pressing the save button.Here all the values should get updated corresponding to the field which i have selected in the first view.
    I want to know how to get the particular field in the selected row from one view to another view.
    Kindly help me.

    Hi,
            Any data sharing accross views can be achiveved by defining CONTEXT data in COMPONENT CONTROLLER and mapping it to the CONTEXT of all the views. Follow the below steps.
    1. Define a CONTEXT NODE in component controller
    2. Define same CONTEXT NODE in all the views where this has to be accessed & changed.
    3. Go to CONTEXT NODE of each view, right click on the node and choose DEFINE MAPPING.
    This is how you map CONTEXT NODE and same can be accessed/changed from any VIEW or even from COMPONENT CONTROLLER. Any change happens at one VIEW will be automatically available in others.
    Check the below link for more info regarding same.
    [http://help.sap.com/saphelp_nw04s/helpdata/EN/48/444941db42f423e10000000a155106/content.htm]
    Regards,
    Manne.

  • Generate Multiple Invoices in One PDF

    Hi,
    I have requirement whereby I need to generate multiple invoices in one PDF file. I am using Oracle BI Publisher with Oracle APEX 4.0.2
    If there is only one invoice that needs to be generated in one PDF file then I already have the solution whereby I print the APEX page item session state values on Invoice Header and get the invoice line items from a SQL Query in my RTF template.
    However how to the do the same when multiple invoice needs to be generated in one single PDF file ?
    Any pointers will highly appreciated.
    Thanks & Regards,
    Ashish

    asagarwal wrote:
    However how to the do the same when multiple invoice needs to be generated in one single PDF file ?It should be pretty straight forward.
    Once you've got the query returning multiple rows, then just add a repeating group to your report (if an existing report, just select the section of the document that will repeat -> add-ins menu -> insert repeating group...; or right click selection -> BI Publisher -> Create group...), wherein the column values exist. You can even specify a page break at the end.
    By the way, this question is probably more suited for the {forum:id=245} forum.
    Ta,
    Trent

  • Add to Multiple Tables from One Page

    Hello,
    I am building an application that handles hardware inventory (APEX 4.0). I have an input page that adds data to two or more tables all at once. The page has two forms on it that point to two separate tables. However when I try to run the page, it fails and returns an error:
    ORA-06550: line 1, column 437: PL/SQL: ORA-00904: "ORH_LAST_UPDATE_DATE": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored
         Error      Unable to process row of table IDD_ID_DATA.
    So far as i can see within the App, that column is not at issue (I am not even doing anything to it and it is nullable). I have looked into the App itself as well as doing some online research but have found nothing helpful...
    So my question is this: Is it possible to add to multiple tables from one page? If so how do I do it?
    I am new to APEX so any help would be greatly appreciated!

    UPDATE:
    I received an email from the APEX Support Team:
    "The simple answer is that you will need to manually code the DML (and query) processes if you wish to maintain multiple tables from one page (There is a limit of one table when using the built-in processes).
    In order to do this I suggest you delete the processes generated by the wizards and create PL/SQL processes with insert, update, delete statements as necessary. Such coding is not difficult but is more time consuming than when you can use built-in processes."
    I have been playing around with PL/SQL code and the end result is this:
    begin
         INSERT INTO table1
         VALUES(
              :P2_Item_Field1,
              :P2_Item_Field2);
         INSERT INTO table2
         VALUES(
              :P2_Item_Field1,
              :P2_Item_Field2);
    end;
    I used this code in a custom PL/SQL Process in the Processing>Processes section of Page Processing and it seems to work fine now. The only downside to this method is if the name of a Page Item is changed the code will also have to be changed. Other than that i have had no problems.

  • Mutiple Rows from a Single Row using SQL

    How can i get Multiple rows from a single row using sql ?
    Example : one row contains the complete address separated by delimiter say comma (,) as address1,address2,city,state,zip,country
    I want to split this row and get the output in multiple rows as address1 address2 city state zip country using sql query.
    Thanks,

    Hi,
    The solution above assumes that the |-delimited entries always contain at least one character. If you have a string like
    1 Elm Street|||Sioux City|IA||it will think 'Siuox City' is address2.
    If you have empty entries, like that, then you need something a little more complicated:
    INSERT INTO table2
    (       address1
    ,     address2
    ,     address3
    ,     city
    ,     state
    ,     postal
    ,     country
    SELECT     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 1), 2)     -- address1
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 2), 2)     -- address2
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 3), 2)     -- address3
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 4), 2)     -- city
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 5), 2)     -- state
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 6), 2)     -- postal
    ,     SUBSTR (REGEXP_SUBSTR ('|' || txt, '\|[^|]*', 1, 7), 2)     -- country
    FROM     table1
    ;

  • Select a single row from a billion row table

    This is a fictitious scenario, how would you write a select statement on a table with a billion rows. It never returns anything,right? Somebody was suggesting a stored procedure.
    As an example : Assuming a Table with columns      Account(int), TransDate(DateTime), TransNum(int) and few other columns. I need a transaction that happened on 03-05-2014 8:15PM. Clustered index on Account. Non- clustered on TransDate.
    I was suggested to create a stored procedure, inside the SP you have 3 parameters: min_date, max_date, avg= min_date+max_date/2. You create a loop and feed the avg value to the max_date or min_date depending on where the row is. This is a suggestion
    that I am not clear my-self but wanted to see if you guys can help me develop this idea.
    Also please suggest how you would do it in your world. You guys could have much better ideas probably much simpler one's. Thanks in advance.
    svk

    I basically just need transaction for one particular datetime. Not any span. One of our senior developers suggested that a simple select statement takes for ever to return a single row from a billion rows and suggested a vague idea as above. 
    Either there is a suitable index on the column, and the SELECT will be fast.
    Or there is no index on the column, and in that case it will take quite some time to find the row. The only reason to loop is that you don't want to take out a table lock, but in that case you would do something like looping one account at a time. Looping
    over different time values will only mean that you will scan the table multiple times.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Generating multiple reports in one rwrun60.exe

    Hello,
    i want to generate multiple documents in one rwrun60.exe
    call (from java). This way i can avoid the time spending
    for logging in to database for every singe report ...
    Does anybody know if its possible ?
    something like
    execute (rdf1, params, rdf2, params) and so on ...
    Greetings
    Thorsten Lorenz

    Every rwrun60.exe call will reconnect to the database. This won't happen if you make the call through the reports server (which will maintain a pool of engines for you).
    Note to the other filer on this thread - run_product() is a forms call, and is not available in as a Java call.
    Regards,
    Danny

  • To Move Multiple Files from one directory to another.

    Hi,
    I need to move multiple files from one directory in UNIX (application server ) to another. I need something like an FM 'STRALAN_COPY_FILES' which is also valid in ECC 6.0.
    Thanks in advance.

    Hello Sachin
    Below you see a copy of how to use EPS_FTP_PUT using transaction SE37.
    Import parameters               Value             
    RFC_DESTINATION =                 NONE              
    LOCAL_FILE             =         filename          
    LOCAL_DIRECTORY   =              /dir1/dir2        
    REMOTE_FILE             =        filename          
    REMOTE_DIRECTORY   =             /dir1             
    OVERWRITE_MODE        =          F        " force -> overwrite existing file                 
    TEXT_MODE                    =   B               " binary
    TRANSMISSION_MONITOR            X       " display transmission monitor            
    *RECORDS_PER_TRANSFER            10                
    *REQUESTED_FILE_SIZE             0                 
    *MONITOR_TITLE                                     
    *MONITOR_TEXT1                                     
    *MONITOR_TEXT2                                     
    *PROGRESS_TEXT                                     
    *OBJECT_NAME  
    Regards,
      Uwe

  • Moving multiple queries from one category to another in QM

    Hi All,
    Is there is any way of moving multiple queries from one category to another in the query manager?
    Or is the only way of doing it by saving each one individually into a different category.
    Any ideas ?
    Regards,
    Rakesh N

    Hi Rakesh,
    The query manager has limited function compare with normal file management applications. Under current design, you have to do this one by one. You just need to make sure move the smaller amount of queries to large category. Category name can be changed easily.
    Thanks,
    Gordon

  • Scenario of multiple Asset from one AUC/WBS

    Hello,
    I am having a requirement, where I need to create multiple Asset from one WBS. I checked in the system and able to create more then 1 Asset for WBS.Also if I maintain the distrubution rules for those Asset then settle it accordingly to different Assets.
    I just wanted to confirm, will it we the right way of handling this scenario? My main concern is this involves intervention of user for maintaing the settlement rule during final settlement.
    Is there any other way to handle this scenario?
    Thanks
    Sarang

    Hello Virendra,
    I am not using Investment Managemnt. What do you mean by IM profile?
    I understand that I need to maintain the source of cost in Source structure. But even in that scenario the user has to go and maintain settlement rules and create multiple Asset against one WBS.
    So how do I tackle it, if client requirement is such that they want to create only one AUC, but during final Asset creation they want to create multiple Assets from one AUC. They dont want to have WBS for each Asset.
    Thanks
    Sarang

  • Creating multiple links from one map image in Flash CS4

    I have been tasked with creating multiple links from one map image using flash. Each link would go to the main website page with that location. I assume I could create a button for each location on the map but not having a lot of experience any help / tutorial you know of would be super helpful.. Thanks! Not looking for someone to work me thru it but a little guidance would be great!

    If I was to answer the problem, I would be giving you what you asked not to be given... the solution.  So I'll suggest that you start by researching the getURL() function.  That is what AS2 uses for opening web pages.
    As for coding a button, I'll recommend the following article for you... it will explain the proper approach to coding a button, which will give you an advantage over others who don't follow it, but instead use the way the article says not to.
    http://www.adobe.com/devnet/flash/articles/as_bestpractices_04.html
    Google is one of the best resources available for learning how to do things with Flash--it's the first place I go when I have a wondering.  In general, if you type in the right keywords, you get fairly good search results.  In your case, combinations of "AS2", "button", "getURL", "tutorial" would probably work well.

Maybe you are looking for

  • Can't Open Files Or Folders By Double Clicking on Its Icon

    I'm unable to open any file or folder by double clicking on its icon whether the icon is on my desktop or in a folder. For example, I can't open my hard disk or any DMG file on desktop by double clicking on its desktop icon, but I can open it or any

  • Zip+4 is blank when tested under addrtest.exe

    HI I am looking at retriving zip4  and started with addrtest.exe which comes with the install. But it always returns me blank for  zip4 here are two exmaples i tested with Executing Addrtest to demonstrate the ACE Library Enter Zip+4 directory (path

  • Need help with a numbers formula

    Hi I am looking for the formula in numbers to do the following apologies if I havn't explained this properly: if I x is greater than y subtract z eg if A2 is greater than 7 subtract 1..... so if A2 was 9 B2 would be 8 but if A2 was 6 B2 would be 6

  • Aparece notificación en ajustes

    En la pantalla de inicio, en el icono de ajustes, aparece un 1 como notificación. Pero no hay nada que actualizar o cambiar y no desaparece

  • Can't connect to FTPS server

    Hi, I have problem with connection to FTPS servers. When I try to connect to my testing virtual server, i get: GnuTLS error -15: An unexpected TLS packet was received. I am using current Filezilla, server software is vsftpd from Debian Squeeze (last