How to append a ResultSet to another ResultSet?

Hi,
How could I append a ResultSet to another ResultSet object if their columns are exactly the same?
For example, I have some methods that return ResultSet objects for particular queries.
int a = 3;
ResultSet rs1 = getRoute(20, a);
ResultSet rs2 = getRoute(a, 40);
ResultSet rs3 = rs1 + rs2;
How do I combine the two ResultSet objects together instead of writing the last statement? Thank you.
-Henry Chang

As I noted earlier, UNION is always going to re-sort your results and remove any duplicate rows; UNION ALL might or might not depending on the database implementation.
I think Oracle happens to be among the databases that will produce a concatenated result FROM UNIUN ALL, without resorting, but if not, and if your database happens to be Oracle, then this will work:
SELECT * FROM
  (SELECT test_table.*, 1 subresult_no, rownum row_no
  FROM test_table
  WHERE column_a = 20 AND column_b = 10
  ORDER BY order_no)
UNION ALL
  (SELECT *, 2 subresult_no, rownum row_no
  FROM test_table
  WHERE column_a = 10 AND column_b = 30
  ORDER BY order_no DESC)
ORDER BY subresult_no, rownum row_no"rownum" is an Oracle feature, it's a pseudo-column that gives the row index at that point in the computation.
The above SQL will of course add 2 columns to your result set; you can of course suppress them by explicitly listing your selected columns; doing so is widely considered to be good practice anyway.

Similar Messages

  • How to append structure dynamically to another structure

    Hi Everyone,
    My requirement is like this.
    PERFORM fill_additional_fields_f16 USING         'RIHAFVC'
                                                            CHANGING <ls_object_tab>.
    FORM fill_additional_fields_f16  USING         iv_structure_name TYPE strukname
                                                      CHANGING  cs_object    type any.
    endform.
    Now my question is how to append the structure IV_STRUCTURE_NAME to CS_OBJECT in the subroutine.
    Thanks in advance
    -Regards
      TOM

    Have a look at the below link.
    https://wiki.sdn.sap.com/wiki/display/Snippets/Add%20a%20column%20to%20an%20internal%20table%20dynamically
    Thanks

  • How to append a gif to another gif in adobe photosop cs5 extended???

    like i have two gif files and i need to apppend 2 gif file at the end of 1st gif file,,so that i 'll a single gif.

    There is no such thing as an "append" with GIF files, since adding frames always affects the color palette, which is global. Ultimately it doesn't matter if you use PS or another tool to add the frames, but of course using e.g. Ulead GIF Animator may be a bit more straightforward than going through the song and dance in PS...
    Mylenium

  • How to find the length of the resultset

    how to find the length of the resultset

    (Doing a select count as somebody suggested is nota
    good solution, as the count can change betweenyour
    count query and your real query.)And the number of rows can't change between getting
    the last one and doing the actual work?I don't think so. Once you've got the ResultSet, I don't think it will change under you, unless you explicitly set it to SCROLL_SENSITIVE.
    I could be mistaken though.

  • How to call one program from another program

    Hai,
      How to call one program through another program.
    Example.
       I have two programs 1.ZPROG1 2. ZPROG2.
    When i execute ZPROG1 at that time it should call ZPROG2.

    Hi ,
    u can use submit statement to call a program .
    DATA: text       TYPE c LENGTH 10,
          rspar_tab  TYPE TABLE OF rsparams,
          rspar_line LIKE LINE OF rspar_tab,
          range_tab  LIKE RANGE OF text,
          range_line LIKE LINE OF range_tab.
    rspar_line-selname = 'SELCRIT1'.
    rspar_line-kind    = 'S'.
    rspar_line-sign    = 'I'.
    rspar_line-option  = 'EQ'.
    rspar_line-low     = 'ABAP'.
    APPEND rspar_line TO rspar_tab.
    range_line-sign   = 'E'.
    range_line-option = 'EQ'.
    range_line-low    = 'H'.
    APPEND range_line TO range_tab.
    range_line-sign   = 'E'.
    range_line-option = 'EQ'.
    range_line-low    = 'K'.
    APPEND range_line TO range_tab.
    SUBMIT report1 USING SELECTION-SCREEN '1100'
                   WITH SELECTION-TABLE rspar_tab
                   WITH selcrit2 BETWEEN 'H' AND 'K'
                   WITH selcrit2 IN range_tab
                   AND RETURN.
    regards,
    Santosh thorat

  • How to append a new entry in a list of 100,000 names without iterating the list each time?

    I have a list of 100,000 + names and I need to append to that list another 100,000 names. Each name must be unique. Currently I iterate through the entire list to be sure the name does not exist. As you can imagine this is very slow. I am new to Java and I am maintaining a 15+ year old product. Is there a better way to check for an existing name?

    We are using a Java list because that is how the original developers coded it. I don't think they planned for that many entry's. I know I need to re factor this which is why I am asking for opinions on how to  make this more efficient. Currently we don't use a database for anything in the product so I would like to stay away from that if possible.
    Ok - but it still raises the question in my mind as to how that data is being used.
    I gave you a couple of options that will take care of the UNIQUE requirement (HashTable, HashMap) but the BEST solution depends on:
    1. How often new entries are made
    2. How often entries are deleted
    3. How often entries are changed
    4. How often entries are accessed
    5. How the data is actually used
    If you just have a one time requirement to merge the two lists then just do it and get it over with - it won't really matter how you do it.
    But Hash classes will present their own performance issues if the typical access is for many, most or all of that 200k+ entries.
    Without knowing the full set of requirements we can't really know just what part of the process needs to be optimized.

  • How to append data in array

    I use three read waveform nodes to read data from three channels of
    oscilloscope. The data of each channel are 1D array, and I use build
    array node to change them into 2D array. It can work well now.
    When I want to continuously reading data, I put the read waveform nodes
    and build array node into a while loop structure(a timer controls the
    time when to stop). That means every time, the program calls read
    waveform nodes and then changes them into 2D array. The problem is:after
    each loop, the data stored in the 2D array are overwrited. So, at last,
    I can only get the last loop data.
    I want to append the data into the 2D array, but I do not know how to
    implement? I have tried put the build array outside the while loop,
    unfortunatel
    y, it does not work.
    Any advice would be appreciated.
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    The shift register is a built in way to carry data forward from one
    iteration of a loop to the next iteration.. Anything that you feed into the
    right shift register appears a data at the beginning of the next loop. You
    already have Build Array to combine three 1D array Elements into a single 2D
    array. Use another Build Array function to combine the current 2D array
    with the previous 2D array to create a combined array. To do this, you must
    change the input mode of the Build Array function to Array (not Element).
    This will concatenate the arrays and make the continuous data that you are
    after.
    The only other hidden step is that you must use Initialize Array to feed a
    blank, 2D array into the left shift register to clear any leftover data.
    Michael Munroe Mailto:[email protected]
    A Better Complete Development Engineering Firm
    San Mateo, CA 94403 http://www.abcdefirm.com
    [email protected] wrote:
    > Because I am very new to Labview and in fact, English is not my native
    > language, I can not understand the sentence that "combine the current
    > reading with the previous reading from the left shift register and save
    > it back to the right shift register" means.
    >
    > Now, I want to descript my question in a simple way:
    > In a while loop, I use a build array node to build three 1D arrays into
    > one 2D array. For each time when while loop repeats, the value of these
    > 1D arrays change, I want to append the new data to the previous ones.
    > But in my program, the data in the build array are overrided after the
    > while loop repeating.
    > So, How to append the data instead of overriding them in the while loop
    > structure?
    >
    > Thanks a lot!
    >
    > zhljh
    >
    > In article <[email protected]>,
    > Michael Munroe wrote:
    > > You need to combine the build array function with the shift register.
    > Pop
    > > up on the edge of the loop and Add Shift Register. You can combine the
    > > current reading with the previous reading from the left shift register
    > and
    > > save it back to the right shift register.
    > > --
    > > Michael Munroe Mailto:[email protected]
    > > A Better Complete Development Engineering Firm
    > > San Mateo, CA 94403 http://www.abcdefirm.com
    > >
    > > [email protected] wrote:
    > >
    > > > I use three read waveform nodes to read data from three channels of
    > > > oscilloscope. The data of each channel are 1D array, and I use build
    > > > array node to change them into 2D array. It can work well now.
    > > > When I want to continuously reading data, I put the read waveform
    > nodes
    > > > and build array node into a while loop structure(a timer controls
    > the
    > > > time when to stop). That means every time, the program calls read
    > > > waveform nodes and then changes them into 2D array. The problem
    > is:after
    > > > each loop, the data stored in the 2D array are overwrited. So, at
    > last,
    > > > I can only get the last loop data.
    > > > I want to append the data into the 2D array, but I do not know how
    > to
    > > > implement? I have tried put the build array outside the while loop,
    > > > unfortunately, it does not work.
    > > > Any advice would be appreciated.
    > > >
    > > > Sent via Deja.com http://www.deja.com/
    > > > Before you buy.
    > >
    > >
    >
    > Sent via Deja.com http://www.deja.com/
    > Before you buy.
    Michael Munroe, ABCDEF
    Certified LabVIEW Developer, MCP
    Find and fix bad VI Properties with Property Inspector

  • I need to append a string to another string

    I'm working with some inherited code, I'm a Colf Fusion
    novice myself, and I'm trying to make this order form display the
    correct data. The problem is a lot of data in the database is
    missing. Description in the QStockDB query can contain a lot of
    stuff. For our full color work the text "4/0", "4/BLACK", and "4/4"
    are consistent so I'm changing the newitem (I know, not very
    descriptive but it's not my code) to CMYK Printing.
    <cfif #QStockDB.description# contains "4/0"><cfset
    newitem = "CMYK Printing"></cfif>
    <cfif #QStockDB.description# contains
    "4/4/BLACK"><cfset newitem = "CMYK Printing"></cfif>
    <cfif #QStockDB.description# contains "4/4"><cfset
    newitem = "CMYK Printing"></cfif>
    I want to then go back through description and compare it
    more to add more description. For instance with this:
    <cfif #QStockDB.description# contains "12 pt"><cfset
    newitem = newitem + " - BC"></cfif>
    I know that the job is a business card. So I want to append
    the newitem variable with " - BC". Likewise:
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem + " - Catalog
    Sheets"></cfif>
    displays CMYK Printing - Catalog Sheets. Or, it should... or,
    more precisely, I want it to. :)
    How do I append a string to another string?

    + is the addiion operator and works with numbers. Because
    your string is a ...well, string... you need to use an ampersand.
    Thus, instead of:
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem + " - Catalog
    Sheets"></cfif>
    Use...
    <cfif #QStockDB.description# contains
    "catalog"><cfset newitem = newitem & " - Catalog
    Sheets"></cfif>
    <cfoutput>#newitem#</cfoutput>
    At least I think that will work - haven't tested it
    though.

  • How to call a report in another report?reply plz

    how to call a report in another report?

    hi,
    chk this.
    *Code used to populate 'select-options' & execute report 
    DATA: seltab type table of rsparams,
          seltab_wa like line of seltab.
      seltab_wa-selname = 'PNPPERNR'.
      seltab_wa-sign    = 'I'.
      seltab_wa-option  = 'EQ'.
    * load each personnel number accessed from the structure into
    * parameters to be used in the report
      loop at pnppernr.
        seltab_wa-low = pnppernr-low.
        append seltab_wa to seltab.
      endloop.
      SUBMIT zreport with selection-table seltab
                                    via selection-screen.
    *Code used to populate 'parameters' & execute report 
    SUBMIT zreport with p_param1 = 'value'
                    with p_param2 = 'value'.
    Other additions for SUBMIT
    *Submit report and return to current program afterwards
    SUBMIT zreport AND RETURN.
    *Submit report via its own selection screen
    SUBMIT zreport VIA SELECTION-SCREEN.
    *Submit report using selection screen variant
    SUBMIT zreport USING SELECTION-SET 'VARIANT1'.
    *Submit report but export resultant list to memory, rather than
    *it being displayed on screen
    SUBMIT zreport EXPORTING LIST TO MEMORY.
    *  Once report has finished and control has returned to calling
    *  program, use function modules LIST_FROM_MEMORY, WRITE_LIST and
    *  DISPLAY_LIST to retrieve and display report.
    Regards
    Anver

  • How to append the data list bod (JList)

    how to append the data list box (JList)
    Message was edited by:
    raju_2reddy

    For this you will need a nested internal table. such that each column of the internal table should be declared as another internal table.
    Try something like this :
    " Lets say that the type of table that will be returned by the function BOM is ty_ret_tab, then declare as follows
    types begin of ty_tab,
    c1 type table of ty_ret_tab,
    c2 type table of ty_ret_tab,
    end of ty_tab.
    data gt_tab type standard table of ty_tab,
            gwa_tab like ty_tab.
    Now the question is how many columns should you declare ? Because you said that in a loop you intend to call a function which will return a internal table and this internal table you need to store in a column of another internal table. And if this is not fixed, you would need to do some dynamic programming to achieve this.
    But if we assume that there are fixed number of columns and fixed number of loops, then within the loop, you wiill have to simply move the data from the returned table to each of the columns. Then append the work area outside the loop.
    data field(30) type c.
    data c_tabix(10) type c.
    field-symbols <fs> type ret_tab.  " this should be
    Loop at itab.
    call function BOM...
    exporting...
    importing.....
    tables  ret_itab.
    c_tabix = sy-tabix.
    concatenate 'C' c_tabix into field.
    condense field.
    assign component  (field) of structure gwa_tab to <fs>.
    <fs> = ret_tab.   " Pass data to each column
    endloop.
    append gwa_tab to gt_tab.  " Now a single record with all columns containing an internal table is built.
    Hope this pseudo code helps.
    BR,
    Advait

  • How can i import contacts from another AIM account to this new one

    If you reference my last ichat question, you will see that I have had serious problems and had to create a new account.
    How can I import contacts from another AIM account to this new one??

    Hi,
    Use AIM for Mac and use the Export and Import features.
    Other than that it is a question on making sure every Single Buddy has more than just their Screen name in the IChat Address Card so it is added to the Address Book and dragging them back from there
    9:08 PM Thursday; February 7, 2008

  • I HAVE AN OLD 3G IPHONE , HOW DO I USE IT IN ANOTHER COUNTRY WITH A NEW SIM CARD

    I  HAVE AN OLD 3G IPHONE , HOW DO I USE IT IN ANOTHER COUNTRY WITH A NEW SIM CARD ?

    it has to be unlocked by your carrier. give them a call

  • HT4994 MY IPHONE IS NOT A SIM FREE HOW CAN I USE IT IN ANOTHER COUNTRY?

    MY IPHONE IS NOT A SIM FREE HOW CAN I USE IT IN ANOTHER COUNTRY?

    Apple can do nothing. As Tim said, only the carrier to whom the iPhone is locked can authorize unlocking. You must contact that carrier.
    Regards.

  • How do I move booksmark to another machine without replacing the bookmarks on the new machine, i.e combine a number of bookmark files

    I'm setting up a laptop and want to have all the bookmarks from my desk machine to be moved there from different accounts, but in end up in one file so that I don't have to have loads of separate accounts.

    You need to combine all the links to one HTML file.
    You only need a file with Anchor links like this:
    <pre><nowiki>
    <a href="https://support.mozilla.com/en-US/questions/754997">How do I move booksmark to another machine without replacing the bookmarks on the new machine, i.e combine a number of bookmark files | Firefox Support Forum | Firefox Support</a></nowiki></pre>
    If you export bookmarks to an HTML file then you create a copy of your bookmarks and you edit that copy and you do not affect the original bookmarks.
    See also [/questions/737050]

  • How can I use Bluetooth with another devices?

    How can I use Bluetooth with another devices?

    You can set up your FaceTime account in Settings > FaceTime.

Maybe you are looking for

  • Need to attavh a file with email message

    Hi All, I need to attach a file to the email message, for the same I am using the function module SO_OBJECT_SEND. but coudl not succeed. Can any one have insight over the function module that how I can use it for a attching a mail to email message. P

  • A suggestion to moderators

    Dear moderators in MM forum, May I made a suggestion? I have received some feedback from my colleagues who are trying their best to contribute in this forum. That some time, which is not so frequent, that their points will be unassigned. I've explain

  • Reset enable password and factory reset LAP1131AG

    HI, I have an LAP1131AG that is configured and has a secret set for enable operations. The file system shows: XXX-AP-XXX>sh flash Directory of flash:/     2  -rwx         256  May 05 2010 18:17:39 +00:00  lwapp_officeextend.cfg     3  -rwx         12

  • MM Purchasing - BW Processkeys

    We have installed the Purchasing Business Content modules but wish to expand it beyond the pesent delivery service use. Presently the Purchase Order Item ODS(0PUR_O01) and Header ODS (0PUR_O02) infoproviders have start routines to to filter records b

  • Can't get my portable hard drive to conect with FCP! What should I do?

    Every time I try to reset my scratch disk to have my media go to my portable hard drive the message "Unable to set scratch disk. Selected directory is on a write protected or non-writable media." How do I change/fix this so my media can be sent to my