How to concatenate multiple records in a single

Hello world:

I want to know if is a way to concat multiple records into one without the help of the sliders. 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 + ',' authors where lan = @lan
return substring (@retvalue, 1, len (@retvalue)-1)
END

That is to say, do not use cursors to concatenate records. However, with ORACLE, I do something like that.

FUNCTION MyConcat(P_Lan IN VARCHAR2) VARCHAR2 IS BACK
v_ret VARCHAR2 (4000);
v_element VARCHAR2 (4000);
v_cursor sys_refcursor;
BEGIN
OPEN to SELECT V_cursor author of authors where Lan = P_Lan
LOOP
SEEK v_cursor INTO v_elemento;
OUTPUT WHEN v_cursor % NOTFOUND;
IF v_ret IS NULL THEN
v_ret: = v_element;
ON THE OTHER
v_ret: = v_ret | ', ' || v_element;
END IF;
END LOOP;
RETURN v_ret;
END;

There is another way to to do?

Best regards
Jack

You can find plenty of examples here:

http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php

and also here:

http://www.sqlsnippets.com/en/topic-11787.html

Published by: hoek on October 21, 2010 17:50

Tags: Database

Similar Questions

  • Data merge: how to get multiple records in a single text?

    Hello

    I'm experimenting with data merging in InDesign CS3. The biggest obstacle I've met tries to get my record flowing continuous text in a single text frame (which would, ideally, "automatic formatting" on the new pages in the document). Records vary considerably in length, and so I can't just create a standard repeat on the page text frame.

    Perhaps, data fusion is not the best way to achieve this and I should be learning to script in place. I feel like I'm just one step, however.

    Any suggestion would be appreciated.

    Data fusion is not thread. There is a nifty script to Rorohiko who will do it for you after the merger, however. Best strategy is to merge, run the script, delete everything except the first image on the first page, then pick up the excess and auto-flux in the document.

  • HP Officejet Pro X476dw (nextworked-Windows 7 Pro) how to scan multiple pages into a single file?

    Does anyone know how to scan multiple pages into a single jpegfile?

    When you scan a document of several pages in a file on a network each page gets its own jpeg image scanend file.

    HP standalone scanner allow generally allows you to add the multuple scans in a jpeg file.

    Any help much appreciated!

    Thank you

    Joihn

    Hello

    Well, I don't know how you can read many jpeg files into a SINGLE file. Put scanned images in a folder is a logical way to keep them in one place. From my understanding single jpeg image may be a ONE page document, but many jpeg images cannot be concatinated to be a multiple page document. We can use images, software publishing to put them in a single document, but still only one page (each image is smaller). Using pdf output, you can concatenate/merge a lot of images in a sinlge multi-page file.

    Kind regards.

  • How to scan multiple pages into a single document using the CanoScan LiDE 200?

    How to scan multiple pages into a single document using the CanoScan LiDE 200?

    I can't find a way to get them to analyze all the time, or a way to put together them later.

    Hi dagda24,

    You can scan multiple pages into a single document with the scan PDF option.  Use the following steps to do:

    1. open MP Navigator.

    2. click on a Clcik.

    3. click Save to PC.

    4. change the Type of PDF file to PDF (multiple pages).

    5 other changes, as needed, and then click Scan.

  • How to scan multiple documents into a single pdf file of ADF on my MX922?

    How to scan multiple documents into a single pdf file of ADF on my MX922?


  • Over my OFFICE JET PRO 8600, how to scan multiple pages into a single document?

    How to scan multiple pages into a single document?

    Thank you

    Hi REDFIERO,

    I can help you scan multiple pages to a file.

    If you use a Mac, you can perform your analysis with HP Scan and when you save the file, choose PDF. Under the PDF Format you chose you will see the option to save all pages in a single file.

    If you are using a Windows operating system, follow the instructions in the following document, Scanning of multiple in a single PDF Pages.

    I hope this helps.

  • How to display multiple images in a single window?

    How to display multiple images in a single window?  I want to compare images side by side, not in tabs.

    The editor preferences > General > turn on enable floating documents, then window > images > float all in windows.

  • How to insert multiple lines using a single query

    Hi all

    How to insert multiple lines using a single query to the emp table?
    I have the number of rows to insert into table x. consumes a lot of time. I tried to insert several lines using a single query, but get errors. I know exactly the query to do this.


    Thank you
    Sunil

    Like this?

    SQL> create table test(id number , dt date);
    
    Table created.
    
    SQL> insert into test values(&a,&b);
    Enter value for a: 1   --- It asked me and I entered 1
    Enter value for b: sysdate  --- It asked me and I entered sysdate
    old   1: insert into test values(&a,&b)
    new   1: insert into test values(1,sysdate)
    
    1 row created.
    
    SQL> 
    

    g.

  • How to view multiple records to a report form - as the model?

    Hi all
    I developed a form - like model report
    I want to show him several records at once (on the same page)
    I tried assigning a value of "Maximum records per page" property for the extensible framework 10
    but when I close the range property and open it again the value returns to 1!
    How to display multiple records on the same page?

    Thank you

    Hello

    check around your formatting images if all have the "vertical stretch" value to the variable or develop.

  • HP ENVY 5540: HAVING HP ENVY 5540 HOW TO SCAN MULTIPLE PAGES INTO A SINGLE PDF

    Trying to scan multiple pages into a single pdf using HPEnvy 5540. Seem to be only able to do it in a single pdf page.  Does not work how to do do.

    Hello

    For Windows, please download and install the following software and install on your computer.

    FTP://FTP.HP.com/pub/scanners/HPScanExt/HPScanExt.msi

    After this, please use it to scan.

    You can also try (for Windows):

    Double-click the icon of the printer on the desktop,
    Select scan a Document or Photo,
    The first page on the glass (face-down)
    Check out the options (size, dpi...) and select scan the document to be filed,.
    Click on Scan - machine will scan the first page
    Delete the first page on the glass, put the second page,
    Click + (plus sign), it sits on the left side of a red x
    Machine will sweep the second page, put 3rd page on the glass and click on + again... until the end and then click Save
    Click done after save

    Kind regards.

  • How to scan multiple pages into a single document

    I use XP SP3 on the HP 510 laptop and printer HP Photosmart 7510e. How to scan multiple pages in 1 document? PDF is also only available document format?

    Thanks for the tips

    Hello

    Please perform the below mentioned steps that should solve the problem.

    Click the icon of the printer (on the desktop), select the scanned under the side of right, notice in the window of advanced settings under file type is a checkbox called "creating a separate file for each scanned page. Make sure it is not checked.

    Kind regards
    Jabzi

    Give Kudos to say 'Thank you' by clicking on the White Star under my name.

    Click on 'accept as Solution' if it has solved your problem, while others may find it.
    I work for HP

  • How to merge multiple images into a single document and place them on the bottom

    I am trying to merge multiple images in a single document and arrange them on this document and save it.  Is it still possible?  There are five black and white drawings that I've resized at all have the same size.  Tutorials that I looked at, but it seems that everyone has another way to do this and all are very confusing.  Thanks for your help.

    It is not surprising that "everyone has a different way to do this." In Photoshop that is common. Try this:

    1. open a new file large enough to accommodate five drawings.

    2. open each design, click on it in the layers panel and drag and drop it in the layers panel to the new file.

    3. Repeat until all are in the new file

    4. use the move tool to reposition. (They are on separate layers)

    5 flatten the file if you wish (but save a version not flattened for future editing)

  • How to put multiple classes in a single file?

    Hello

    I would like to put multiple classes in a single file. (This would be useful for grouping children who are minor extensions of the parent classes or helper classes that are used by a class only).

    When I tried to combine two classes in a file, I got this error message:
    5006: an ActionScript file cannot have several definitions visible from the outside: Notation.editField, Notation.labelField1

    It is the structure I used. Thanks in advance for your help.

    You can declare multiple classes in a single file, but only one can be
    in the package declaration. All statements outside the package class
    are invisible to code outside the file.

    sample package
    {
    public class SampleClass
    {
    }
    }

    class SampleClassHelper
    {
    }
    class SampleClassHelper2
    {
    }

  • Insert multiple records in the single form

    Hi all

    I met already insert many rows into a table using ADF BC. The solution is in the following thread

    Re: How to create several new lines in the Table of the ADF?

    However,.
    The above solution is useful when you want to enter new values as well as all the table entries is displayed.
    What can I do if I don't want all values in the table, but just a page 'AddEntries' where I can only add new lines without going through the table entries is displayed.

    As,

    Say a form has 5 rows

    Each line has empId, eMailSlNo, send attributes

    EmpId is the same for all 5 recordings but emailId is different.

    EmpId eMailSlNo plus the PK.

    empId generated by the sequence.

    Now, on presentation of the form, I want all five records to be inserted.

    (can I use ADF form instead of the table of the ADF for the ViewObject in this case. I tried ADF form but I could only insert 1 plug at the same time).

    I use 10.1.3.4

    Help, please.

    Thanks in advance,
    Shri

    Published by: newtoOTN on December 29, 2009 18:02

    Shri salvation,

    ADF form is intended for the single insert/update. For multiple insert/update/delete using the collection as table UI is preferred. I guess your db table or table design INTERFACE default (in my opinion but I do not know your usecase entirely, so I guess might b wrong).

    I would say,

    -make EmpId as PK
    -have another table to store EmpId (foreign key), emailSiNo, email
    -Having the relationship of the master / detail between the British Colombia ADF db tables.
    -Create master / detail UI and on the selection of the master, view the details and if no record is found does not add files and commit.

    See these examples:
    http://www.Oracle.com/technology/products/jdev/tips/Mills/MasterDetailSync/Master_Detail_Synchronization_in_ADF_Faces.html
    http://andrejusb.blogspot.com/2007/06/create-edit-and-delete-operations-in.html

    Hope it makes sense.

    ~ K

  • Concatenate multiple columns in a single string

    Hello

    I use Oracle 11.2, how can I concatenate values from multiple columns in a string with an SQL:

    create table testTb (number (5) classId, class varchar2 (32));

    Insert into the testTb value (101, 'room101');
    Insert into the testTb value (101, 'room201');
    Insert into the testTb value (101, 'room301');
    Insert into the testTb value (202, 'room444');
    Insert into the testTb value (202, 'room555');

    I would like to generate the result as following:

    Class 101 is room101, room201, room301
    202 class is located in room444, room555

    Thank you

    Please post sample data.
    11.2 you can use LISTAGG:

    SQL> select 'Class '||classid||' is in '||listagg(classroom, ', ') within group (order by classroom)
     str
      2  from   testtb
      3  group by classid;
    
    STR
    --------------------------------------------------------------------------------
    Class 101 is in room101, room201, room301
    Class 202 is in room444, room555
    
    2 rows selected.
    
    SQL> 
    

Maybe you are looking for

  • Re: The Portege Z930 battery life

    Hello everyone! I have no problem with my new Toshiba (I hope I won't have any in the future), but I wanted to ask you guys for the advice on the maintenance of the batteries. Some people recommend taking the battery when you use your pc attached to

  • Help for tone control utility for Windows Vista x 64

    Hi, I have a HDX X 16-1375DX . I change windows and I can not find: Tone Control Utility for Windows Vista x 64 Driver (this package provides the utility of the tone (Bass/Treble) HP control. Please help me find that. Thank you

  • How to display a value according to the position of the arrow of the mouse?

    Hello world I change the color of the background of some indicators according to temperature measurements. Each context is bound to a temperature. I want to show the value of the temperature during the passage of my mouse on the indicator arrow. I do

  • Programtries to load at startup that I'm not sure.

    A startup name program: (5BB4B692-C213-DAD1-E621-571CE305F4CO), file: c:\documents and settings\myname\application data\faagge\cuavt.exe tries to load at startup. What kind of program is this and should I allow this program use or continue to block?

  • Access denied on the editing of the files in c:\program files\

    HelloI just install win7pro on my laptop, there are application installed in my c:\program files and the need to change (it's a text file) I can open it but not able to edit and save the file, it says access denied and need administrator privilege, I