How to concatenate multiple records into one

Hi everybody:
I want to know if exist some way to concat multiple records into one without using cursors. For example, I have a table named "Authors" like this:
Lan|Author
English|Ernest Hemingway
Spanish|Octavio Paz
Spanish|Mario Vargas Llosa
English|Sinclair Lewis
Spanish|Gabriel García Márquez
And I want to get this:
Author
Octavio Paz, Mario Vargas Llosa, Gabriel García Márquez
I have worked with SQL Server and I can do something like this:
CREATE FUNCTION dbo.MyConcat (@lan varchar(10))
RETURNS varchar(5000) AS
BEGIN
declare @retvalue varchar(5000)
set @retvalue=''
select @retvalue = @retvalue + Author +',' from Authors where lan = @lan
return substring(@retvalue,1,len(@retvalue)-1)
END
ie, do not use cursors to concatenate records. However, with ORACLE, I have to do someting like this.
FUNCTION MyConcat(P_Lan IN VARCHAR2) RETURN VARCHAR2 IS
v_ret VARCHAR2(4000);
v_element VARCHAR2(4000);
v_cursor sys_refcursor;
BEGIN
OPEN v_cursor FOR SELECT Author FROM Authors where Lan = P_Lan
LOOP
FETCH v_cursor INTO v_elemento;
EXIT WHEN v_cursor%NOTFOUND;
IF v_ret IS NULL THEN
v_ret := v_element;
ELSE
v_ret := v_ret || ', ' || v_element;
END IF;
END LOOP;
RETURN v_ret;
END;
Exist some other way to do this?
Best Regards
Jack

Tks both for answer... I forgot to mention that I am using Oracle 10g. I read about LISTAGG() but this function is available for Oracle 11g release 2.
I wil read about the other techniques than Hoek mention
Best Regards.
Jack

Similar Messages

  • Concatenate multiple records into one single record

    Hello everyone,
    Can anyone guide me how to merge multiple records into one single record
    like......... I am getting the data in the file like
    aaaaa/bbbbbbb/ccccccccccc/dddddddddddd/eee
    ffffff/gggg/hhhhhhhhhhhhhh
    /123/4567/55555/99999999/kaoabfa/eee
    fffff/kkkkkkkk/llllllllllllllllllllllll
    when i use gui_upload I am getting the data into the internal table in the above format.
    My main intension is to split the record at / to multiple lines and dowload it into another file.
    What i am planning to do is... if the line does not start with / then i want to concatenate the multiple lines into single line and then split it into multiple records. Can anyone guide me how to achieve this.

    Yes, it should work.
    In my example
    Loop at itab.
    concatenate i_text itab into i_text.
    endloop.
    You change that loop for the loop of your internal table with the file records
    So if you have this three records
    'aaaa/bbb/ccc'
    '/dddd/efg'
    'hijk/lmn'
    i_text will look like this at the end
    'aaaa/bbb/ccc/dddd/efghijk/lmn'
    then in this part of the code
    split i_text at '/' into table itab2.
    itab2 will have the records looking like this
    aaaa
    bbb
    ccc
    dddd
    efghijk
    lmn'

  • HT4059 I'm trying to organize my PDFs in iBooks on my ipad2 and I can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

  • Concatenate multiple columns into one string

    Hello,
    I am using Oracle 11.2, how can I concatenate the value of multiple columns into one string with one SQL:
    create table testTb(classId number(5), classRoom varchar2(32));
    insert into testTb value(101, 'room101');
    insert into testTb value(101, 'room201');
    insert into testTb value(101, 'room301');
    insert into testTb value(202, 'room444');
    insert into testTb value(202, 'room555');
    I would like to generate the result as followings:
    Class 101 is in room101, room201, room301
    Class 202 is in room444, room555
    Thanks,

    Hi,
    Since you're using Oracle 11.2, you can use the aggregate LISTAGG function:
    SELECT       'Class ' || classid
                   || ' is in '
                 || LISTAGG ( classroom
                         ) WITHIN GROUP (ORDER BY classroom)
                   AS txt
    FROM       testtb
    GROUP BY  classid
    ;The generic name for concatenating all the strings in a group is String Aggregation . This page shows several ways to do it, suitable for different versions of Oracle.

  • How to invite multiple people into one chat?

    when using the app why can't i invite multiple people into one chat i can only do one on one? just curious.
    [Topic title updated by moderator to be more descriptive. Original topic title was: "the app"]

    I'm using the Skype app on IOS but the only way to have multiple people in one chat together we have to do it from a computer but not all of us have a computer on hand but we do have our phones and or tablets with us I was just wonder the the app didn't have those capabilities.

  • How to get multiple elements into one element as multiple occurences

    I can't figure out how to do this. I have an input message that has multiple elements and I need to take those elements and copy them into one element with each new element going in as a new occurence or instance. For example
    I have this input under one parent node.
    element1
    element2
    element3
    element4
    and this is the output I need
    Node
    Element1[0]
    Element2[1]
    Element3[2]
    Element4[3]
    The input XML looks like this
    Payload
    Element1
    Element2
    Element3
    and the output XML needs to look like this
    Payload
    Element.
    Thanks in advance

    How about this.
    Input XML:
    <Row>
              <Column1>TOTAL</Column1>
              <Column_9_2_2008>900</Column_9_2_2008>
              <Column_9_2_20082>890</Column_9_2_20082>
              <Column_9_3_2008>52</Column_9_3_2008>
              <Column_9_4_2008>0</Column_9_4_2008>
              <Column_9_4_20082>0</Column_9_4_20082>
              <Column_9_5_2008>0</Column_9_5_2008>
              <Column_9_5_20082>0</Column_9_5_20082>
              <Column_9_8_2008>0</Column_9_8_2008>
              <Column_9_8_20082>0</Column_9_8_20082>
              <Column_9_9_2008>0</Column_9_9_2008>
              <Column_9_9_20082>0</Column_9_9_20082>
              <Column_9_10_2008>0</Column_9_10_2008>
              <Column_9_10_20082>0</Column_9_10_20082>
              <Column_9_11_2008>0</Column_9_11_2008>
              <Column_9_11_20082>0</Column_9_11_20082>
              <Column_9_12_2008>0</Column_9_12_2008>
              <Column_9_12_20082>0</Column_9_12_20082>
              <Column_9_15_2008>0</Column_9_15_2008>
              <Column_9_15_20082>0</Column_9_15_20082>
              <Column_9_16_2008>0</Column_9_16_2008>
              <Column_9_16_20082>0</Column_9_16_20082>
              <Column_9_17_2008>0</Column_9_17_2008>
              <Column_9_17_20082>0</Column_9_17_20082>
              <Column_9_18_2008>0</Column_9_18_2008>
              <Column_9_18_20082>0</Column_9_18_20082>
              <Column_9_19_2008>0</Column_9_19_2008>
              <Column_9_19_20082>0</Column_9_19_20082>
              <Column_9_22_2008>0</Column_9_22_2008>
              <Column_9_22_20082>0</Column_9_22_20082>
              <Column_9_23_2008>0</Column_9_23_2008>
              <Column_9_23_20082>0</Column_9_23_20082>
              <Column_9_24_2008>0</Column_9_24_2008>
              <Column_9_24_20082>0</Column_9_24_20082>
              <Column_9_25_2008>0</Column_9_25_2008>
              <Column_9_25_20082>0</Column_9_25_20082>
              <Column_9_26_2008>0</Column_9_26_2008>
              <Column_9_26_20082>0</Column_9_26_20082>
              <Column_9_29_2008>0</Column_9_29_2008>
              <Column_9_29_20082>0</Column_9_29_20082>
              <Column_9_30_2008>0</Column_9_30_2008>
         </Row>
    Output XML:
    <Total>
              <Payload>900</Payload>
         </Total>
         <Total>
                   <Payload>890</Payload>
         </Total>
         <Total>
                   <Payload>52</Payload>
         </Total>

  • How to store multiple records for one master reocrd using sequnce

    dear,
    my question is in one form i have master block f and detail block.
    my question is i created one sequence and assign to master table. but i dont know how to assign that sequence to multiple record in detail table for that particular master record. i got lots of answer previously but i m not getting exactly.pls tell me full procedure otherwise gv me one demo application
    NOTe: the sequnce is created after master record commiting to database.
    PLS pls help me
    Thanks
    damby

    i did not get answer pls help me.

  • How to populate multiple records into 1 using addtl keyfigs

    Hi Gurus,
    Please take a look at this scenario.
    I have 3 records coming from source system.
    ex:
    key dateid startdate enddate
    c    1      d1         d2
    c    2      d3         d4
    c    3      d5         d6
    i need to populate these 3 records as one into the infoobject based on dateid.
    (dateid =1 then kf1=d1,kf2=d2;dateid =2 kf3=d3,kf3=d4 dateid = 3 kf1=d5,kf2=d6)
    i added 6 key figures ( kf1 kf2 kf3 kf4 kf5 kf6) as attributes to infoobject.The final
    record should look like the below one.
    key kf1 kf2 kf3 kf4 kf5 kf6
    c d1 d2 d3 d4 d5 d6
    Could you pls give me some thoughts on how to do this in a better way.
    Do i need to write update routine or just the formula in update rule is enough  ??
    Thanks in advance
    -dooDle

    Hi Ramesh,
    The scenario you have mentioned looks really complicated reason being, maintainance.
    Combining 3 records to one is possible in Start Routine. But it will be an expensive one.(I mean loopin)
    Pseudo code:
    LOOP AT DATA_PACKAGE.
    Check which records satisfy your criteria and fill a Temporary table. The fields will be your entire record to be appended to the fact table.
    Endloop.
    Delete your Data Package.
    populate the Temporary Internal Table onto the Data Package.
    Hope it helps.
    Regards,
    Praveen.

  • How to concatenate two colums into one single column

    I need some ideas to concatenate two different columns into one single column using a set of distinct values.
    For Example,
    Customer Product Number
    xyz A 1
    xyz B 2
    xyz B 1
    AAA C 7
    AAA A 1
    The result should look like this,
    Customer Value
    xyz A1 B2 B1
    AAA C7 A1
    How would I group this into once value ?
    Thanks in advance ...

    Tom's discussion of writing your own aggregate routines
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2196162600402
    starts off with a link to the 8i alternatives
    "see
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:229614022562
    for 8i methods (not aggregates)"
    Unforutnately, it's a lot more work in 8i.
    Justin

  • Concatenate multiple tables into one table

    Dear all,
    I am doing migration between two database structures, that's why I need also to know if we want to concatenate the data in tables A,B and C into one table in the destination schema, what is the strategy to do this knowing that I have a lot of data and I need the fastest solution.
    regards

    Since the details of your requirements are unclear, will this approach not work ?
    SQL> INSERT into target_table
    SQL> (SELECT * from tableA UNION
    SQL>  SELECT * from tableB UNION
    SQL>  SELECT * from tableC);HTH
    Srini

  • How to connect multiple endpoints into one straight one line

    Hello everybody,
    I made a sihlouette of buildings and I"m wanting to connect the bottom open endpoints into one straight line. The reason I'm doing this is because I want to add a fill to the sihlouette as a whole instead of doing them one by one.
    I tried joining paths but it can only be two open endpoints at a time. As you can see with the picture below, I have many open endpoints.
    The pen tool only joins two open endpoints. If I try to continue to try to add another endpoint to the same line, the pen tool becomes a "minus anchor point" tool and messes up the shape of the buildings.
    Of course, I thought of just making each building seperate and grouping them together. However, if I do that, a issue occurs because I have certain buildings that are "in front" of each other (not in the sense of layers, but the image as a whole). I purposely made the sihlouette look like some buildlings are in front of each other and some are behind each other.
    I hope I am making sense. I don't even know if what I am doing is possible.
    I added a picture below so everybody can see what I am trying to achieve. Any help would be greatly appreciated.

    Thank you all for being very helpful. As you can see, I have much to learn.
    @Jonika
    I have tried the pathfinder but the images become messed up and not exactly the way I want it.
    @jacobbugge
    I did and this is what happens.
    I tried to do that in the first place but it wasn't working so I'm stuck trying to figure out a different way.
    To everybody else:
    What I eventually want to do is to do a clipping mask so I can use a picture that will show up on the inside of the buildings. And if I do it the way it is right now, it won't necesarily fill in all of the buildings. If you see the picture above, it cuts off the areas that have no endpoints to the other side.
    The buildings that have two points on the bottom, I am able to fill without connecting the endpoints. That is true. However, for example, the far left and the far right buildings, do not fill correctly because they do not have an endpoint that is right next to it that it can connect to. This is getting difficult to describe haha.
    The front buildings are no problem. However, the buildings "behind" the other buildings, how can I get these to fill in all the way?

  • How to combine multiple webservices into one WSDL file

    Gurus,
    I have 4 four webservices(ws1,ws2,ws3 & ws4) defined in XI. Normally in XI when we define webservice ,WSDL file will be generated for each interface. Now I have 4 related interfaces, so 4 WSDL files will generated. Suppose if I have 100 webservices then 100 WSDL files need to be generated & need to send to other party to consume our services, which is very tedious task & to track also. So is it possible to combine related webservices into one WSDL file? Your inputs will be highly appreciated.
    Regards,
    Santhosh

    Hi,
             Instead of trying to combine the interfaces, you can try to define your interface mapping with 4 sender interfaces with in one interface mapping . I think this may give you the result you are expecting.
                      If you want entire content to be in one interface , then, define single interface which can accomadate, all message ocntent of all 4 interfaces.Means your sender message to contain the 4 datatypes internally.
    Regards,
    Reyaz

  • How to merge multiple files into one pdf

    I would like help with this task. If I could do this for free I woul actually be more likely to follow advice. Many thanks

    Hi Lauravill,
    The free Adobe Reader cannot help you with the merging job. If you have Acrobat Reader then you can merge files into one pdf with the following steps-
    Within Acrobat XI, select File > Create > Combine Files into a Single PDF.
    Click Add Files and select the files you want to add.
    Click, drag, and drop to reorder the files and pages. Double-click on a file to expand and rearrange individual pages. Press the Delete key to remove unwanted content.
    When finished arranging the files, click Combine Files.
    Select File > Save As > PDF.
    Name your PDF file and click Save.
    Let us know if you face any problemwith this or need extra support.
    Thanks
    -Satyadev

  • How to join multiple tracks into one NOT from CD

    I have mp3s which I added to my library. There's annoying pauses between then on my ipod. I want to make all 13 of these tracks into one track. Is there a way to do this? This is not from an audio cd that I can join track, this is in mp3 format already on my desktop.

    Check out Doug Adams' Join Together.
    Also, 3am Coffee's offering a bunch of scripts that will do the same thing, but unlike Doug's, these guys want $10.
    Lita

  • How to Print multiple Records under one level in Etext templates.

    Hi,
    I am working on the Etext templates and customizing the standard template “US NACHA PPD FORMAT”.
    This standard template don’t have a addenda record.. I have modified and it is working for single Addenda records. But when I have multiple ADDENDA records to be printed in one particular *<outboundpayment>* level, it is not printing.
    How do I modify the template so that Multiple Addenda records get printed?
    Note:     I have multiple *<MyPayables>* tags under *<OutboundPayment>* tags.
    Please help me in understanding this…
    Regards
    Pradeep G

    What you probably need to do is generate each bio
    individually with the
    <cfdocument...> tag just the way you want them. And
    then use some of
    the advanced <cfpdf...> functionality that allows you
    to append two or
    more individual PDF's into a single large PDF.
    Here are some resources that describe some of the
    <cfpdf...> functionality.
    http://www.coldfusionjedi.com/index.cfm/2007/7/9/ColdFusion-8-Working-with-PDFs-Part-1
    http://www.coldfusionjedi.com/index.cfm/2007/7/10/ColdFusion-8-Working-with-PDFs-Part-2
    http://cfpdf.blogspot.com/
    http://cfpdf.blogspot.com/2007/06/cfpdf-action-merge_27.html
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=cfpdf_02.html

Maybe you are looking for

  • Jtree custom nodes

    Hi there, the "How to Use Trees" tutorial shows how to create simple JTrees where each node is a String: http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html I need to have tree structure where each node is like a form entry. For exam

  • Service Request Detail Report Data Definition...Where is It?

    Hi All, Can anyone help me find the data definition associated with the Service Request Detail report? Here are the specifics and I am in R12 Module: Service (CS) The report name is: Service Request Detail The short code for this report is: CS_SR_DET

  • Why did creative cloud install new 2014 software instead of updating the previous installed CC software to CC (2014)

    With the update to creative cloud and the new CC (2014) version, I am wondering why the old CC versions were not updated. The reason I ask is that I now have two versions of Photoshop CC, where one is the 2014 version.  I have the same with Premier P

  • What is error code ox80092013

    What is error code ox80092013 I get this when I download itunes.

  • Internet User & org structure in SNC

    Hi Experts, I'm kind of new to SNC. can someone explain what is - 1- Internet user in SNC. how to create this user. hiw different is this from SU01 user? 2- how to link this user to business partner person.? 3- Is it required to create a organisation