Combining two single recordset into one two column recordset

Hi Forum
Assume we have three types , each 'table of'
CREATE OR REPLACE type type1 as table of number ;
CREATE OR REPLACE type type2 as table of varchar2 (255);
CREATE OR REPLACE TYPE TYPEVALUE AS OBJECT
(object_type number ,
object_value varchar2(255)
resultset1 type1 := type1() ;
resultset2 type2 := type2() ;
resultset3 typevalue := typeValue3() ;
I want to populate records of resultset3 from resultset1 and resultset2 , using resultset1 for first column of record and resultset2 for second column.
One way is to do for loop but I don't want to use this.
I need something similar to resultset3 to use it dynamically in select statement to do MINUS operation with another resultset . I think things like MULTISET, COLLECT, CAST can achieve what I want to do.
Can you please help me to have a select statement that combines two single column rowset and put into a two column recordset.
Thanks

Hi,
You can do something like this:
SQL> create or replace type type1 as table of number;
  2  /
Type created.
SQL> create or replace type type2 as table of varchar2(255);
  2  /
Type created.
SQL> create or replace type typevalue as object(object_type number, object_value varchar2(255));
  2  /
Type created.
SQL> create type typevalue_tab as table of typevalue;
  2  /
Type created.
SQL> ed
  1  declare
  2     resultset1 type1 := type1(1, 2, 3, 4, 5);
  3     resultset2 type2 := type2('one', 'two', 'three', 'four', 'five');
  4     resultset3 typevalue_tab;
  5  begin
  6     for l_res in (
  7        select typevalue(t1.col1, t2.col2) as col
  8        from (
  9           select column_value col1
10           , rownum rn
11           from table(cast(resultset1 as type1))
12        ) t1
13        , (
14           select column_value col2
15           , rownum rn
16           from table(cast(resultset2 as type2))
17        ) t2
18        where t1.rn = t2.rn
19     )
20     loop
21        dbms_output.put_line(
22           'Object Type:  '||l_res.col.object_type||' '||
23           'Object Value: '||l_res.col.object_value
24        );
25     end loop;
26* end;
SQL> /
Object Type:  1 Object Value: one
Object Type:  2 Object Value: two
Object Type:  3 Object Value: three
Object Type:  4 Object Value: four
Object Type:  5 Object Value: five
PL/SQL procedure successfully completed.All the work here is done in SQL so it should work similarly if you have these things defined as nested table columns in the database.
However, there is a caveat here: the lines highlighted in bold above are defining an arbitrary ordering for the nested table elements using rownum, as there is no concept of ordering within a nested table. You should change this part of the query to whatever makes sense in your environment, otherwise this solution cannot be guaranteed to be correct. Another option would be to use VARRAYs, as they will retain the order of elements.
cheers,
Anthony

Similar Messages

  • Is it possible to combine two pivot report into one ?..

    Is it possible to combine two pivot report into one ?..
    Then trying to display a chart or table result.

    Thanks for the reply.
    Let me explain it briefly. I am creating a Report 1 based on one fitler condition and second report is created based on second filter condition.
    I have similar column (time periods) in the both report. Then measure column has to combine and show as single report.
    This is my requirement.

  • How can I combine two itunes accounts into one?

    How can I combine two itunes accounts into one?

    Items purchased from the iTunes Store are permanently associated with the account from which they were originally purchased.  Apple provides no way to change this.
    However, if you wish to put content from two accounts into a single iTunes library, you can easily do so.  Use the command File > Add File (or Folder) to Library.

  • Reg: Combining two display lists into one list

    Dear All,
    i want to combine two display lists into one display list. Please give the idea for this one issue.
    *****************dispaly list 1 starting here*********************
    *&      Form  F_006_DISPLAY_LIST
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_006_DISPLAY_LIST.
    *  TABLES : LFA1 .
      DATA : V_DEBIT_TOTAL TYPE P DECIMALS 2 ,
             V_CREDIT_TOTAL TYPE P DECIMALS 2 ,
             V_CLOSE_BAL TYPE P DECIMALS 2 .
      DATA : V_CNT TYPE I .
      SORT ITAB_OPG BY LIFNR.
      LOOP AT ITAB_OPG.
        NEW-PAGE.
    * Displaying Vendor Name
        SELECT SINGLE NAME1 FROM LFA1 INTO LFA1-NAME1 WHERE
                                                 LIFNR EQ ITAB_OPG-LIFNR .
        FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
        WRITE:/2 'Vendor Code:' ,
                 ITAB_OPG-LIFNR  ,
              40 LFA1-NAME1 .
        CLEAR : LFA1 .
        WRITE :/(190) SY-ULINE .
    * Displaying Opening Balance
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON .
        READ TABLE ITAB_OPG WITH KEY LIFNR = ITAB_OPG-LIFNR .
        IF ITAB_OPG-BAL LE 0 .
          WRITE :/2 'Opening Balance for Period' , (4) S_MONAT-LOW , ':' ,
                  171(18) ITAB_OPG-BAL .
        ELSE.
          WRITE :/2 'Opening Balance for Period' , (4) S_MONAT-LOW , ':' ,
                  151(18) ITAB_OPG-BAL .
        ENDIF.
        WRITE :/(190) SY-ULINE .
    * Displaying Line Items
        LOOP AT ITAB_DISPLAY WHERE LIFNR EQ ITAB_OPG-LIFNR.
          V_CNT = SY-TABIX MOD 2.
          IF V_CNT EQ 0.
            FORMAT COLOR COL_NORMAL INTENSIFIED ON.
          ELSE.
            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
          ENDIF.
    * Selecting Bank Name and Cheque Number
          SELECT SINGLE CHECT HBKID INTO (PAYR-CHECT , PAYR-HBKID)
                               FROM PAYR WHERE
                        ZBUKR EQ P_BUKRS AND
                        VBLNR EQ ITAB_DISPLAY-BELNR AND
                        LIFNR EQ ITAB_DISPLAY-LIFNR .
          SELECT SINGLE BANKS BANKL INTO (T012-BANKS , T012-BANKL) FROM
                 T012 WHERE BUKRS EQ P_BUKRS AND
                            HBKID EQ PAYR-HBKID.
          SELECT SINGLE BANKA INTO BNKA-BANKA FROM BNKA WHERE
                            BANKS EQ T012-BANKS AND
                            BANKL EQ T012-BANKL .
          WRITE :/2 ITAB_DISPLAY-BUDAT ,
                 14 ITAB_DISPLAY-BELNR ,
                 26 ITAB_DISPLAY-BLDAT ,
                 40 ITAB_DISPLAY-XBLNR ,
                 58(16) PAYR-CHECT ,
                 75 BNKA-BANKA ,
                105(40) ITAB_DISPLAY-SGTXT ,
                146(4) ITAB_DISPLAY-BLART .
    * Determinig Debit or Credit
          IF ITAB_DISPLAY-SHKZG EQ 'S'.
            V_DEBIT_TOTAL = V_DEBIT_TOTAL + ITAB_DISPLAY-DMBTR.
            WRITE:151(18)  ITAB_DISPLAY-DMBTR ,
                  171(18)  SPACE .
          ELSEIF ITAB_DISPLAY-SHKZG EQ 'H'.
            V_CREDIT_TOTAL = V_CREDIT_TOTAL + ITAB_DISPLAY-DMBTR.
            WRITE:151(18) SPACE ,
                  171(18)  ITAB_DISPLAY-DMBTR .
          ENDIF.
          CLEAR : T012 , BNKA , PAYR .
        ENDLOOP.
        FORMAT COLOR COL_TOTAL INTENSIFIED ON.
        WRITE:/(190) SY-ULINE.
    * Displaying Debit and Credit Totals
        WRITE:/125 TEXT-001 ,
           151(18) V_DEBIT_TOTAL ,
           171(18) V_CREDIT_TOTAL .
        WRITE:/(190) SY-ULINE.
    * Displaying the Closing Balance
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
        V_CLOSE_BAL = ITAB_OPG-BAL + V_DEBIT_TOTAL - V_CREDIT_TOTAL .
        IF V_CLOSE_BAL GT 0.
          WRITE:/122 TEXT-002 ,
             151(18) V_CLOSE_BAL NO-SIGN.  " D00K909674
        ELSEIF V_CLOSE_BAL LE 0.
          WRITE:/122 TEXT-002 ,
             171(18) V_CLOSE_BAL NO-SIGN.  " D00K909674
        ENDIF.
        CLEAR : V_CLOSE_BAL.
      ENDLOOP.
    ENDFORM.                               " F_006_DISPLAY_LIST
    *****************dispaly list 1 ending here*********************
    *****************dispaly list 2 starting here*********************
    *&      Form  F_006_DISPLAY_LIST1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_006_DISPLAY_LIST1 .
    TABLES : KNA1 .
      DATA : V_DEBIT_TOTAL1 TYPE P DECIMALS 2 ,
             V_CREDIT_TOTAL1 TYPE P DECIMALS 2 ,
             V_CLOSE_BAL1 TYPE P DECIMALS 2 .
      DATA : V_CNT1 TYPE I .
      SORT ITAB_OPG1 BY KUNNR.
      LOOP AT ITAB_OPG1.
        NEW-PAGE.
    * Displaying Vendor Name
        SELECT SINGLE NAME1 FROM KNA1 INTO KNA1-NAME1 WHERE
                                                 KUNNR EQ ITAB_OPG1-KUNNR .
        FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
        WRITE:/2 'Customer Code:' ,
                 ITAB_OPG1-KUNNR  ,
              40 KNA1-NAME1 .
        CLEAR : KNA1 .
        WRITE :/(190) SY-ULINE .
    * Displaying Opening Balance
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON .
        READ TABLE ITAB_OPG1 WITH KEY KUNNR = ITAB_OPG1-KUNNR .
        IF ITAB_OPG1-BAL1 LE 0 .
          WRITE :/2 'Opening Balance for Period' , (4) S_MONAT-LOW , ':' ,
                  171(18) ITAB_OPG1-BAL1 .
        ELSE.
          WRITE :/2 'Opening Balance for Period' , (4) S_MONAT-LOW , ':' ,
                  151(18) ITAB_OPG1-BAL1 .
        ENDIF.
        WRITE :/(190) SY-ULINE .
    * Displaying Line Items
        LOOP AT ITAB_DISPLAY1 WHERE KUNNR EQ ITAB_OPG1-KUNNR.
          V_CNT1 = SY-TABIX MOD 2.
          IF V_CNT1 EQ 0.
            FORMAT COLOR COL_NORMAL INTENSIFIED ON.
          ELSE.
            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
          ENDIF.
    * Selecting Bank Name and Cheque Number
          SELECT SINGLE CHECT HBKID INTO (PAYR-CHECT , PAYR-HBKID)
                               FROM PAYR WHERE
                        ZBUKR EQ P_BUKRS AND
                        VBLNR EQ ITAB_DISPLAY1-BELNR AND
                        KUNNR EQ ITAB_DISPLAY1-KUNNR .
          SELECT SINGLE BANKS BANKL INTO (T012-BANKS , T012-BANKL) FROM
                 T012 WHERE BUKRS EQ P_BUKRS AND
                            HBKID EQ PAYR-HBKID.
          SELECT SINGLE BANKA INTO BNKA-BANKA FROM BNKA WHERE
                            BANKS EQ T012-BANKS AND
                            BANKL EQ T012-BANKL .
          WRITE :/2 ITAB_DISPLAY1-BUDAT ,
                 14 ITAB_DISPLAY1-BELNR ,
                 26 ITAB_DISPLAY1-BLDAT ,
                 40 ITAB_DISPLAY1-XBLNR ,
                 58(16) PAYR-CHECT ,
                 75 BNKA-BANKA ,
                105(40) ITAB_DISPLAY1-SGTXT ,
                146(4) ITAB_DISPLAY1-BLART .
    * Determinig Debit or Credit
          IF ITAB_DISPLAY1-SHKZG EQ 'S'.
            V_DEBIT_TOTAL1 = V_DEBIT_TOTAL1 + ITAB_DISPLAY1-DMBTR.
            WRITE:151(18)  ITAB_DISPLAY1-DMBTR ,
                  171(18)  SPACE .
          ELSEIF ITAB_DISPLAY1-SHKZG EQ 'H'.
            V_CREDIT_TOTAL1 = V_CREDIT_TOTAL1 + ITAB_DISPLAY1-DMBTR.
            WRITE:151(18) SPACE ,
                  171(18)  ITAB_DISPLAY1-DMBTR .
          ENDIF.
          CLEAR : T012 , BNKA , PAYR .
        ENDLOOP.
        FORMAT COLOR COL_TOTAL INTENSIFIED ON.
        WRITE:/(190) SY-ULINE.
    * Displaying Debit and Credit Totals
        WRITE:/125 TEXT-001 ,
           151(18) V_DEBIT_TOTAL1,
           171(18) V_CREDIT_TOTAL1 .
        WRITE:/(190) SY-ULINE.
    * Displaying the Closing Balance
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
        V_CLOSE_BAL1 = ITAB_OPG1-BAL1 + V_DEBIT_TOTAL1 - V_CREDIT_TOTAL1 .
        IF V_CLOSE_BAL1 GT 0.
          WRITE:/122 TEXT-002 ,
             151(18) V_CLOSE_BAL1 NO-SIGN.  " D00K909674
        ELSEIF V_CLOSE_BAL1 LE 0.
          WRITE:/122 TEXT-002 ,
             171(18) V_CLOSE_BAL1 NO-SIGN.  " D00K909674
        ENDIF.
        CLEAR : V_CLOSE_BAL1.
      ENDLOOP.
    ENDFORM.                    " F_006_DISPLAY_LIST1
    *****************dispaly list 2 ending here*********************
    Thanks,
    Sankar M

    Hi,
    Can you post it as two halves ?
    Regards,
    Swarna Munukoti

  • How do I combine two different libraries into one?

    I have three devices, one iphone and two ipods. How can I combine all three libraries into one single library. Is this possible?

    Choose the library connected to the iPhone, import the media content from the other one/two libraries. DeDupe.
    I've written a script called DeDuper which can help with the last bit. See this  thread for background.
    tt2

  • Search view : Combine two search views into one serch view

    Hi ,
    We have a requirement for combining two search views into one and display single result view consisting of some fields from One search and few fields from other search.
    Ex. There are two seperate search views for Oppotunity and Quotation. Now we want to combine search views of both into one search view with selected fields and then display a single result view with combined fields from both result views .
    Kindly suggest me the steps I can follow to achieve the same.
    Thanks,
    Madhura

    Hi,
    This is possible by creating dynamic views in a window.
    1)create views you required.
    2)create a tray in the view 1 and a link and set the properties.
    3)create an outbound plug for the view1 and save the application.
    4)create one more link in the tray for view1 and set the properties and create one more outbound plug.
    5)go the main view view and create 2nd tray and create a UI container element in it.
    6) now embed view1 and view2 in the container .........................
    <removed_by_moderator>
    regards,
    Muralidhar .C
    Edited by: Stephen Johannes on Jan 26, 2010 7:53 AM

  • How do I combine two PDF files into one?

    I want to merge two PDF files into one to make things easier when I take the file(s) to a professional printer.
    Can I do this in Preview?
    Thanks.

    You can't do in Preview.
    You can combine individual PDFs into one PDF using one of these freeware utilities.
    PDFMergeX @ http://www.malcom-mac.com/blog/pdfmergex/
    joinPDF @ http://www.macupdate.com/info.php/id/16604
    Combine PDFs @ http://www.monkeybreadsoftware.de/Freeware/CombinePDFs.shtml>
    PDFLab (join & split) @ http://pdflab.en.softonic.com/mac
     Cheers, Tom

  • How do I combine two slide shows into one?

    I need to combine two slide shows into one and put the whole thing into a loop for a Kiosque. Can someone help?

    Drag and drop the slides from the Thumbnail viewer (left side of the window) from one Keynote to the other. They should copy with all the Actions and Transitions still in place. Then go to Inspector>Document Tab and check the box that says to Loop slideshow.

  • Combining two sales documents  into one billing document

    Hi Friends,
    I need to combine two sales document into one billing document. Header data is same in both sales document.
    I have set factory calendar in the payer master.
    Tried for data transfer rotine at copy control of item level. But was not sure which routine to be set.
    Please let me know, what all settings are required to create one combine billing document.
    Regards
    Suman

    Hi,
    Is it delivery based billing or order based billing?
    2 orders / 2 deliveries and 1 invoice.
    For the above situation you need to write a routine which eliminates document number difference for Reference and Allocation.
    If you do not have different customer purchase orders for these two sales orders and in your copy control from delivery to billing your assignment and reference numbers are blank then system will club these deliveries and create one sales order.
    Else you need to eliminate these by writing a copy control routine and assign it at the header level.
    Hope this helps.  Pl. revert in case of further clarifications.
    Thanks
    Krishna.

  • Combine two date field into one timestamp field

    Hello all,
    I need help combining two date fields into one timestamp field.
    I have separate Date and Milliseconds fields and want to
    combine to one Timestamp field can some suggest sql???

    This is my data
    01 JAN 1989 12:01:00.001 AM
    this is my insert drag_time is a timestamp field in another schema
    INSERT
    INTO DRAG (drag_time)
    SELECT to_char(drag_time, 'DD MON YYYY HH12:MI:SS')||(drag_second)||to_char(drag_time, ' AM')
    FROM sa.drag;
    This is the error
    ERROR at line 3:
    ORA-01855: AM/A.M. or PM/P.M. required

  • How to merge two storage drives into one partition-help

    THis is on an iPad-Please excuse for any typos
    I Am working on a project of restoring a macbook pro from old parts that I found. It works!!! But the HDD that i salvadged is ancient and gets about .15 MBPS. Not good. Its an apple certified and apple branded toshiba HDD-500G at 5400RPM. Yeah. *****
    I am considering buying a new hard drive as a 480GB SSD, and using OWC's Data doubler, adding a second HDD, for all the photos and vids i will be collecting through my work in video and photo. I am considering getting an SSHD (SSD+HDD in an SSD form factor) and using this as the second drive. its not much more expensive (like 10$ more) and itgetsme semi-SSD like performance on a mass scale of storage.
    HOw can I combine these two drives into ONE partition? 480GB will take awhile to fill up, but this is a future proof wall to use.
    I Will eventually invest in an external storage option (2-3 HDDS in one caddy for backups and storing 1080p video all under one roof. depends if the board im using actually has thunderbolt or usb that is fast enough-because of the crappy hdd i cant get it to boot into an OS or go through usb recovery without it freezing. I ahve tried re-applying thermal paste, still doesnt help)
    HOw can i easily partition these two drives into one?
    also, my friend needs a new HDD because bootup times in his macbook pro are at like 2 mins+ and hes running Core 2 Duo, with 8 G ram and 10.9 (Mav) should i recommend an SSHD or an ssd. (He doesnt want an HDD, hes had bad 'voodoo' with em'. Thanks!

    nithya_ram wrote:
    Give me d source code for merging two img files into one img file\\
    If you want someone to do your work for you, simply pay someone. However, if you have a question about code you're currently working on, feel free to ask a specific question here on the forum.

  • Merging two LDAP directories into one clean 10.4 server.

    What I have now is two different OD masters. One is a 10.3.9 server and the other is a 10.4.9 server. What I want to do is combine the two Open Directories into one on a brand new Xserve 10.4.9 install, and make that my only master with several replicas.
    I'm trying to do as much research as possible before attempting this feat. I haven't been able to find much on here via searching. I did however, find this link (http://www.afp548.com/article.php?story=20050615173039158&query=migrate), which should be quite helpful, but I was wondering if anyone on here had anymore input.
    Thanks in advance.

    Hi Celia
    I think you could achieve this using slapcat with a bit of ldapadd/ldapmodify? Manual pages should tell you more?
    Not done it myself with 10.5 but I don't see why not? Export desired information as LDIF file(s). You could do it for for both LDAP Servers and then bring them in. They should just add to each other?
    Worth a try?
    Tony

  • How can I use two single-dimensional arrays-one for the titles and array

    I want to Use two single-dimensional arrays-one for the titles and one for the ID
    Could everyone help me how can i write the code for it?
    Flower
    public class Video
    public static void main(String[] args) throws Exception
    int[][] ID =
    { {145,147,148},
    {146,149, 150} };
    String[][] Titles=
    { {"Barney","True Grit","The night before Christmas"},
    {"Lalla", "Jacke Chan", "Metal"} };
    int x, y;
    int r, c;
    System.out.println("List before Sort");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);
    System.out.println("\nAfter Sort:");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);

    This is one of the most bizarre questions I have seen here:
    public class Video
    public static void main(String[] args) throws Exception
    int[] ID = {145,147,148, 146,149, 150};
    String[] Titles= {"Barney","True Grit","The night before Christmas", "Lalla", "Jacke Chan", "Metal"};
    System.out.println("List before Sort");
    for(int i = 0; i < Titles.length; i++)
       System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles);
    System.out.println("\nAfter Sort:");
    for(int i = 0; c < Titles.length; i++)
    System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles[i]);
    Generally you don't use prefix (++c) operators in you for loop. Use postfix (c++).
    Prefix means that it will increment the variable before the loop body is executed. Postfix will cause it to increment after.

  • HT204053 Can you merge two Apple IDs into one?  It was a common issue caused by the iPhone 4 and has been corrected, but transferring purchases in iTunes is a pain with two IDs.

    For a brief time when iPhone 4, iOS 4 came out, many of us ended up with two Apple IDs.  I want to know if anyone can please provide me with simple step-by-step instructions on merging two Apple IDs into one?  It would make transferring purchases on iTunes much easier and reliable.  I realize i desperately need an iOS update, but i had no laptop for over two years!  I'm posting a cry for help on that in another community.  Thank you all.

    No,
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.

  • Merge two PDF files into one with Adobe Reader

    Does anyone know how to merge two PDF files into one with Adobe Reader. Is it even possible?
    Thanks

    If you've got a Mac and OSX you can do this in Preview.  Make sure you can see the sidebar with the first PDF opened, and then drag the second PDF to the bottom of the last page in the sidebar.  Also you can reduce the size of your saved file by selecting (or making) a Quartz filter to 'reduce file size'
    Cheers

Maybe you are looking for