How to concat detail records in one line

Hi,
I would like to concat all empoyees and it as column next to department name, like that
DEPTNO DEPTNAMR EMPLIST
Is there any way to do it using select without user-define function to concat emp records
Im using O10R2
Thanks & best regard

Take your pick, these examples span several database versions:
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

Similar Messages

  • 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

  • How to make several pushbuttons in one line (on screen)??

    How to make several pushbuttons in one line (on screen)??
    thanks in advance!!!!

    Hi,
    USE
    SELECTION-SCREEN BEGIN OF BLOCK.
    SELECTION-SCREEN BEGIN OF LINE.
    define all buttons between this block.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK.
    selection-screen
    Cheers
    VJ

  • How to put detail records in fixed formÉ

    Hi,
    I am trying to build a crystal report based on an existing printed form. The form includes elements that look like the following:
    Activity
    Hot Oiler - 4 mbtu     7mbtu
    Pressure Pumping - 5K   10K   15K
    Travel - 5K   10K   15K
    Standby - 5K   10K   15K
    Each Activity also has a quantity, a rate, and a total (quantity * rate) associated with it.
    The user used to circle the applicable value on the paper form (for example, if it was a 4 mbtu hot oiler vs. a 7 mbtu hot oiler).
    In the application and database the user will enter line items in the work order that specify if it is a Hot Oiler  4 mbtu or a Hot Oiler 7mbtu.  Similarly, the user will create a record that is either Pressure Pumping 5k or Pressure Pumping 10K or Pressure Pumping 15K. And so on.
    The application is capturing all of this information.  I want the crystal report to still display each of these elements as they are laid out on the current paper form however because these are detailed records I do not know how to place them in the report properly. If we take the first line in the form, I created the formula:
    +if {field_tickets_has_resources.resources_id} in [150, 151] then
    "Hot Oiler - " & "4 mbtu" else
    if {field_tickets_has_resources.resources_id} = 163 then
    "Hot Oiler - " & "7 mbtu" else
    "Hot Oiler - "+
    I created another formula for the second line in the form:
    +if {field_tickets_has_resources.resource_roles_id} = 15 then
    "Pressure Pumping - 5K" else
    if {field_tickets_has_resources.resource_roles_id} = 18 then
    "Pressure Pumping - 10K" else
    if {field_tickets_has_resources.resource_roles_id} in [22, 24] then
    "Pressure Pumping - 15K" else
    "Pressure Pumping -"+
    And so on.  However, I cannot place each of these formula beside each other in a details line because it places the values horizontally rather than vertically in the report.  I cannot place these in a header because they are actually detailed records.
    I hope this makes sense. Any help, as always, is appreciated!
    Mark

    Hi Mark, 
    I recommend a similar apporach but the first formula will be created so we can group the records by the Activity type.  For example all the Hot Oilers then Pressure Pumping, etc. 
    We group on this formula then a second formula will build a list of the quantities. 
    One final formula in the Group Footer will display everything on a single line.  We can then hide the Group Header and Detail section because we only want to see one line per actvity type. 
    Create a group on this formula:
    @ActivityGroup
    If {field_tickets_has_resources.resources_id} <> 0 Then
       "Hot Oiler"
    Else If {field_tickets_has_resources.resource_roles_id} <> 0 Then
             "Pressure Pumping";
    This formula will define and reinitialize a string variable for each group.  This goes into the Group Header and can be suppressed. 
    @Initialize        
    WhilePrintingRecords;
    StringVar myQuantity := "";
    This formula goes into the Detail section.  Based on your first formula I'm guessing the Activity Type is based on which field is populated.  I assume only one field per record can have a value that isn't 0. 
    @Quantity        
    WhilePrintingRecords;
    StringVar myQuantity;
    If {field_tickets_has_resources.resources_id} <> 0 Then
       (Select {field_tickets_has_resources.resources_id}
          Case 150  :myQuantity := myQuantity & "4 mbtu "
          Case 151  :myQuantity := myQuantity & "4 mbtu "
          Case 163  :myQuantity := myQuantity & "7 mbtu ";)
    Else If {field_tickets_has_resources.resource_roles_id} <> 0 Then
       (Select {field_tickets_has_resources.resource_roles_id}
          Case 15   :myQuantity := myQuantity & "5K "
          Case 18   :myQuantity := myQuantity & "10 "
          Case 22   :myQuantity := myQuantity & "15K "
          Case 24   :myQuantity := myQuantity & "15K ";)
    This formula goes into the Group Footer and builds your string. 
    @Display     
    WhilePrintingRecords;
    StringVar myQuantity;
    {@ActivityGroup} & "-" & myQuantity;
    All the sections except for the Group Footer can be formatted to hide. 
    Hope this helps,
    Brian

  • How to display selected records on one HTML page?

    Hi,
    I would like to display selected part of records on one page in HTML region. For example I have a Master - Detail table set named Procedures and Tasks (each Procedure can have one or more tasks)
    I would like to be able to display all Tasks for a given Procedure in one HTML region on a page... The problem is that the number of tasks vary between procedures and can change in time. Also, the 'task description' can be very large so a simple report list of all tasks is something I cannot use... (I would like eg for the task name to be here, and the task_description to be there - unlike the report where everything is in one line...) The following are my ideas but non of them seemed to be feasable here...
    1. Use a report based on vertical columns (However I am using Theme 10 for which there are no vertical column templates. The only vertical templates I can see are the default ones but I have no idea how to customize them - where are they?)
    2. In HTML region use &ITEM_NAME. substitutions. In order to display more than one &EMN_NAME. (based on eg. EMPID) I suspect that I would need to write some kind of javascript loop. Has anyone have an idea about how would such a script look like?
    3. Display each Task in a separate screen. This is something I would want least but better than nothing - to have a customized report which would display one task at a time with some kind of pagination to it...
    Please let me know if someone has tried something simmilar or maybe there is a 4th option which will be simpler and easier...
    Many thanks,
    Pawel.
    I tried to make a very simple illustration of what I would like to achive here:
    http://htmldb.oracle.com/pls/otn/f?p=44995:3:9461299983704828937::::
    Message was edited by:
    padmocho

    Just to answer this one myself....
    In order to achive the above I used a PL/SQL Dynamic Content page and entered a html content in htp.prn('');
    Then, I created a PL/SQL LOOP which searches through the various rows...
    In the end, whenever I wanted to display html content I just used htp.prn and for variables I used htp.p(<var_name>);
    Maybe, it helps ;)

  • How to control detail records displayed after requery

    I have a master/detail form. I did not like the behavior of the screen clearing after I did a save so I added code to requery the master/detail records. There is still one behavior which I need to fix -- after I requery the master and detail records, I always get the first set of detail records, not the set of records displayed on the screen when I did the save. So if I have detail rows 40-50 displayed on the screen and do a save, the master/detail rows are requeried but I see rows 1-10 on the screen, not 40-50. Any ideas how to code around this?

    This is due in part to the fact that detaching the detail object from its master and actually deleting the detail object are two different things. To work around this, add the following in your session bean, where Departments and Employees are your master/detail objects, respectively:
    public void removeNestedEmployee(Employees entity) {
    Departments owningDept = entity.getDepartment();
    owningDept.removeDepartment(entity);
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.deepMergeClone(owningDept);
    Object empWorkingCopy = uow.readObject(entity);
    uow.deleteObject(empWorkingCopy);
    uow.commit();
    Re-generate the data control for this session bean and then drag and drop this method onto your JSF page. The argument you'll pass in is the data provider for the selected employee:
    ${bindings.departmentCollectionIterator.currentRow.dataProvider}
    This will both detach the record from the owning entity, delete the record, and force a refresh of both the master and detail iterators.
    Hope this helps,
    Lynn Munsinger
    Oracle JDeveloper and ADF Product Management

  • How to get the results in one line

    Hi
    if i use the script below i get the name of path and then : and in next line i get the results.is there a way to get the results from every path after the : and not in the next line?
    another question - is there a way that the script will not show the server name on every path?
    (Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter
    THC

    If you take you script and pipe it to get member, it will give you a list of various script properties.
    (Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter | get-member
    You will see that the object type returned by "Get-Counter" is Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet.
    TypeName:
    Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet
    Name MemberType Definition
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    ToString Method string ToString()
    CounterSamples Property Microsoft.PowerShell.Commands.GetCounter.Perfo...
    Timestamp Property datetime Timestamp {get;set;}
    Readings ScriptProperty System.Object Readings {get=$strPaths = ""...
    You can try grabbing different properties, and they will print out differently, displaying the data on the same line in some cases. For example, pipe your output to a "foreach-object" block, and then for each object print out the CounterSamples property.
    (Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter | foreach-object { ($_).CounterSamples }
    This should all print on one line now. However, you also asked if there was a way to not have the server print out on every line. The way to control the format of these outputs is to use the "format-table" cmdlet. So you would pipe your output to format-table
    and then give it various options. This is how you would pipe it (without any options).
    (Get-Counter -ListSet LogicalDisk).PathsWithInstances |
    Get-Counter | object { ($_).CounterSamples | format-table }#OR USE YOUR ORIGINAL CODE(Get-Counter -ListSet LogicalDisk).PathsWithInstances |
    Get-Counter | format-table }
    Now, it's up to you to give format-table the options you want. With no options, output will look unchanged. To see what options are available to you, use get-help.
    get-help format-table
    I hope this helps!
    Thank for all the info...

  • How to insert some records in one table and some records in another table

    Interview question
    how insert records in two tables by using trigger
    CREATE or REPLACE TRIGGER Emp_Ins_Upd_Del_Trig
    BEFORE delete or insert or update on EMP
    FOR EACH ROW
    BEGIN
    if UPDATING then
    UPDATE emp2
    SET
    empno = :new.empno,
    ename = :new.ename
    --, job = :new.job
    --, mgr = :new.mgr
    --, hiredate = :new.hiredate
    , sal = :new.sal
    --, comm = :new.comm
    --, deptno = :new.deptno;
    sdate = :new.sdate,
    edate = :new.edate
    end if;
    if INSERTING then
    INSERT INTO emp2
    VALUES
    ( :new.empno
    , :new.ename
    --, :new.job
    --, :new.mgr
    --, :new.hiredate
    , :new.sal
    --, :new.comm
    --, :new.deptno
    new.sdate,
    new.edate);
    end if;
    if DELETING then
    DELETE FROM emp2
    WHERE empno = emp2.empno;
    end if;
    END;
    it is working fine but he wants to insert some specific litimit on one table and some specified limit of records in one ..
    In this senerio can i insert records by use count of records...
    please help me..

    Can you be more specific on the "Limit"
    Conditional insert can be used in this case.

  • How to Print Multiple Barcode in one line

    Hi All,
    I am printing barcode using <c1>&lwa_itab-matnr</>. now i have a query i want to print in the same line one more bar code with the values. but i m not able to print it. will any one pls help me out in this how i will print more than one barcode in one line.
    i have tried this syntax also
    <c1>&lwa_itab-matnr&      &lwa_itab-matnr&</>.
    But it is not giving gap between two barcode. it is considering space and converting space also in barcode which i don't want. I want to print two barcodes separately with some space. How will i do this.
    Pls answer it. it is very urgent.
    I am doing this in smartforms.
    Thanks
    Garima
    Edited by: Garima Mittal on Jun 18, 2008 12:34 PM

    hi,
    try like this.
    <c1>field1_</c1>_      <c1>field2_</c1>_
    give the two fields in the same line.
    so this will help u in printing the barcodes in the same line
    please reward me if helpful.
    regards,
    Reddy.

  • How can I make a custom one-line-per-test rpt using TestStand?

    I have written a 1-line-per-test report in another LabView application.  How can I do the same within TestStand 4.0?  I would like to display the usual information:  Description, Measurement Reading & Units, Pass/Fail, Lower Limit, and Upper Limit all in a concise, one line rpt.  Isn't most of this data available within TestStand?

    I would have figured this to be a pretty common use case, so I was wondering if anyone has made/edited a report sequence that does this?
    For example, the default report text looks something like:
    UUT Report
    Serial Number:                MACADDRGoesHere
    Date:                         Monday, September 22, 2008
    Time:                         9:48:05 PM
    Operator:                     administrator
    UUT Result:                   Passed
    Begin Sequence: MainSequence
    (C:\Projects\Corventis\1-08-01641-Corventis-Gen1 PCBA Test System\Engineering\3 - Develop\Sandbox\Report Generation Demo\Report Generation Demo_Main.seq)
    V_CPU_2V5 (Device Off):        Passed
         Measurement:              0.3000
         Units:                    V
         Limits:
            Low:                   0.1000
            High:                  0.5000
         Comparison Type:          GELE (>= <=)
         Module Time:              0.0014
    Memory DataBus Test POST:      Passed
         Module Time:              0.0012
    V_BATT:                        Passed
         Measurement:              3.1200
         Limits:
            Low:                   3.0000
            High:                  3.2000
         Comparison Type:          GELE (>= <=)
         Module Time:              0.0009
    End Sequence: MainSequence
    End UUT Report
    whereas I'd love something like:
    UUT Report
    Serial Number:                MACADDRGoesHere
    Date:                         Monday, September 22, 2008
    Time:                         9:48:05 PM
    Operator:                     administrator
    Execution Time:               0.2188 seconds
    Begin Sequence: MainSequence
    (C:\Projects\Corventis\1-08-01641-Corventis-Gen1 PCBA Test System\Engineering\3 - Develop\Sandbox\Report Generation Demo\Report Generation Demo_Main.seq)
    Test Name        Result        Measurement        Units        Limit Low        Limit High        Comparison Type        Module Time
    V_CPU_2V5 (Device Off)        Passed        0.3000        V        0.1000        GELE (>= <=)        0.0014
    Memory DataBus Test POST        Passed        N/A        N/A        N/A        N/A        N/A        0.0012
    V_BATT        Passed        3.1200        3.0000        3.2000        GELE (>= <=)        0.0009
    End Sequence: MainSequence
    End UUT Report 
    Message Edited by crelf on 09-22-2008 10:19 PM
    Message Edited by crelf on 09-22-2008 10:19 PM
    Copyright © 2004-2015 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.

  • How do I scroll more than one line at a time in Firefox 4? Scrolling with down-up keyboard arrows is much faster in IE/Chrome.

    I have tried using about:config options mousewheel.withnokey.sysnumlines > false and custom set mousewheel.withnokey.numlines, but it makes a difference only when I use a mouse, which I don't use most of the time on this laptop. I use down/up keyboard errors to scroll, and the page scrolls one-line-at-a-time, very slow and lagging. Is there a way around this?
    I have reinstalled Chrome as secondary browser only because of this, FF4 otherwise really kicksass. Thank you for an amazing browser and any feedback on my issue.

    Well I am using those, but it is not very practical. What puzzles me is that only Firefox has this behaviour, I have tried last versions of IE, Chrome, Opera - all three scroll much faster than Firefox 4 using down/up keyboard arrows.
    Thanks for the reply, I really hope to get a solution to this.

  • How to bring the url in one line ?

    Hi Experts,
    - I have used a Url in the smartfrom.
    - When the link comes through in an email it the format seems messed up because it's forcing it to be all on one line.  I think it might work better if it was possible to make this a hyperlink instead of typing the whole address.
    Can we try the basic <a href="http://cgtapp61.esc.win.colpal.com:8061/sap/bc/bsp/sap/crm_ui_frame/default.htm?sap-client=321&sap-sessioncmd=open">CRM System Login</a> - Like this
    Is this possible in the smartfrom ?
    Please Help.
    Prem.

    Hi prem kumar,
    In the smartstyles -->
    create the character format -->
    Font tab -->check the check box underline and color blue.
    save and activate.
    In the smartform inlcude smartstyle in the output options tab .
    Create the text node select the text and display as URL.
    Regards,
    Sravanthi

  • 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 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

  • Copy value from first detail record to next detail record only one field is

    Hi all
    i have a detail form with this table
    CREATE TABLE customer_detail (
      cust_id NUMBER,
      aDDRESS_type VARCHAR2(20),
      contact_name VARCHAR2(100),
      mobile_no VARCHAR2(20),
      delivery_address VARCHAR2(300),
      off_contact_no VARCHAR2(20),
      email_id VARCHAR2(50),
      city VARCHAR2(50),
      pin_code VARCHAR2(50),
      country VARCHAR2(30),
      contact_name_1 varchar2(100),
      contact_name_2 varchar2(100),
      MOBILE_NO_1 VARCHAR2(20),
      MOBILE_NO_2 VARCHAR2(20),
      OFF_CONTACT_NO_1  VARCHAR2(20),
      OFF_CONTACT_NO_2  VARCHAR2(20),
      EMAIL_ID_1 VARCHAR2(50),
      EMAIL_ID_2 VARCHAR2(50)
       );i enter a record in this table through form and the addess_type = 'INVOIVE ADDRESS'
    i want when i save this one record and i want to save same to same record in this table the addres_type will change
    address_type='DELIVERY_TYPE' as a next record
    PLease Guide
    Thanks And Regards
    Vikas Singhal
    Edited by: vikas singhal on Sep 17, 2009 12:09 PM

    Hi!
    May there is already a delivery address for that customer in the table, so it is a good choice
    to just insert a new record 'DELIVERY ADDRESS' if there is no one.
    May try a pre-insert trigger:
    begin
    if
      :address_type = 'INVOICE ADDRESS'
    then
      insert into customer_detail
      select :cust_id, 'DELIVERY ADDRESS', :contact_name, :mobile_no, :delivery_address,
             :off_contact_no, :email_id, :city, :pin_code, :country, :contact_name_1,
             :contact_name_2, :MOBILE_NO_1, :MOBILE_NO_2, :OFF_CONTACT_NO_1, :OFF_CONTACT_NO_2,
             :EMAIL_ID_1, :EMAIL_ID_2
      from dual
      where not exists ( select 1 from customer_detail
                         where cust_id = :cust_id
                         and   address_type = 'DELIVERY ADDRESS' );
    end if;
    end;You could do the same, if you insert a new 'DELIVERY ADDRESS' and there is no 'INVOICE ADDRESS'.
    Regards

Maybe you are looking for

  • How to connect my Macbook Pro to play dvds on my TV

    What cables and which output ports are best to play DVDs on my Macbook pro and displaying the movies on my TV? I was thinking the video output would be either "mini display" or "firewire" and the audio would be the headphone audio out port, but I'm g

  • Allow multiple users to log on to a pcs

    Hello I work for a company and at the minute we have 8 meeting rooms and in those meeting rooms there is 8 mini pcs. At the moment the only people that are allowed to log on to this pc are admins because in ad under our accounts we have the option 'l

  • How many elements can I insert into a form?

    When creating my form I received a notice that I had reached the maximum number of elements for my form!  I was near the end stages of my design, Ouch!  What can I do?  Is it possible to cut and past sections of my form to create a new form(s) and li

  • Using Reports 3.0.5 with Oracle 10G database

    We are in the process of upgrading from Oracle 8.0.5 to 10g running under Windows 2000.. Everything has been done using Developer Forms(5.0.6.8.0) and Reports(3.0.5.8.0). In testing the Forms seem to be OK. Some of our reports work and some don't. Wh

  • Reason 4 levels quiet in logic???

    I am using Reason 4 and logic together. When using a redrum, subtractor, etc... from Reason I can never get any volume out of them when rewired to Logic. For example: I tried a couple kick samples playing a pattern in redrum and in the logic mixer it