Help in using listagg function for more than 8000 char.

Hi Friends,
Need you urgent help in using listagg function for more than 8000 char.
I did the below sample SQL and in "e_orig" and "d_orig" for upto 4000 char it is working fine but I have to use it for more than 8000 char. and it is giving error,
I checked the listagg function is having limitation of 4000 char.
I tried but I am unable to achive this. Can someone provide me a sample example to achive this
select d.dname,d.loc,e.hiredate
,listagg(e.ename,',' ) within group (order by e.deptno) over (partition by e.deptno) as e_orig
,listagg(e.ename, ',') within group (order by e.sal) over (partition by e.deptno) as d_orig
from emp e, dept d
where e.deptno=d.deptno;[ This is my first post, I gone through the guideline for posting a post , and try to go according to that ( I have not pasted here create table and insert as I have used basic table emp, dept for example), please let me know if still I should give this, I will take care from my next post ]
Thanks in advance

Interesting, I didn't know you could do that, but...
BluShadow wrote:
You could write some PL/SQL code that does it all for you, but that would involve loops and would be slow.Well, objects are written in PL/SQL aren't they? And presumably there'll be implicit looping too? So it's not at all obvious that this method will be faster than doing the joining in PL/SQL in memory. The only way to find out is to benchmark them - so I have done that.
I noticed that OP's ref cursor actually only ever retrieves a single record for a bound department number, so I decided the best thing would be to test using a procedure that passes an output string back. I selected all (109) employees and put spaces in to ensure above 4000 characters. I also noticed that as he is using PL/SQL he probably can use a VARCHAR2 type, but just not ListAgg in the query, so I wrote short procedures as follows:
SimpleAggChr     - bulk collect and array processing, VARCHAR2 output
ClobAggPrc     - the custom aggregation method, CLOB output
SimpleAggClob     - bulk collect and array processing, CLOB output
I then wrote a driving script that calls them in the order above and times each call (I like benchmarking so I have my own timing object to make it easy). I then print the lengths for checking, and my object writes the timings to my output table. Running a few times I got varying results, but generally it looks like there isn't a lot to choose between them for performance.
Here's the procedure code:
CREATE OR REPLACE TYPE char100_list_type AS TABLE OF VARCHAR2(100)
CREATE OR REPLACE PROCEDURE SimpleAggChr (x_out OUT VARCHAR2) IS
  l_enames     char100_list_type;
BEGIN
  SELECT first_name || '                                        ' || last_name
    BULK COLLECT INTO l_enames
    FROM employees
   ORDER BY salary;
  FOR i IN 1..l_enames.COUNT LOOP
    x_out := x_out || l_enames(i) || ',';
  END LOOP;
END SimpleAggChr;
CREATE OR REPLACE PROCEDURE SimpleAggClob (x_out OUT CLOB) IS
  l_enames     char100_list_type;
BEGIN
  SELECT first_name || '                                        ' || last_name
    BULK COLLECT INTO l_enames
    FROM employees
   ORDER BY salary;
  FOR i IN 1..l_enames.COUNT LOOP
    x_out := x_out || l_enames(i) || ',';
  END LOOP;
END SimpleAggClob;
SHO ERR
PROMPT ClobAggPrc
CREATE OR REPLACE PROCEDURE ClobAggPrc (x_out OUT CLOB) IS
BEGIN
  SELECT clobagg(first_name || '                                        ' || last_name || ',')
    INTO x_out
    FROM employees
   ORDER BY salary;
END ClobAggPrc;
SHO ERRand the driving script:
SET SERVEROUTPUT ON
SET TIMING ON
DECLARE
  l_enames_c1     CLOB;
  l_enames_c2     CLOB;
  l_enames_v     VARCHAR2(32767);
  l_timer     timer_set_type := timer_set_type ('Aggregation');
BEGIN
  Utils.g_id := 'Aggregation';
  SimpleAggChr (l_enames_v);
  l_timer.Increment_Time ('SimpleAggChr');
  ClobAggPrc (l_enames_c1);
  l_timer.Increment_Time ('ClobAggPrc');
  SimpleAggClob (l_enames_c2);
  l_timer.Increment_Time ('SimpleAggClob');
  DBMS_Output.Put_Line ('SimpleAggChr returned string of length ' || Length (l_enames_v));
  DBMS_Output.Put_Line ('ClobAggPrc returned string of length ' || Length (l_enames_c1));
  DBMS_Output.Put_Line ('SimpleAggClob returned string of length ' || Length (l_enames_c2));
  l_timer.Write_Times;
END;
SET TIMING OFF
SET LINES 150
SET PAGES 1000
COLUMN id FORMAT A30
COLUMN line_text FORMAT A120
SELECT line_text
  FROM output_log
WHERE id = 'Aggregation'
ORDER BY line_ind
/and the results:
SimpleAggChr returned string of length 5779
ClobAggPrc returned string of length 5779
SimpleAggClob returned string of length 5779
PL/SQL procedure successfully completed.
Elapsed: 00:00:27.05
LINE_TEXT
Timer Set: Aggregation, constructed at 03 Nov 2011 16:27:07, written at 16:27:35
================================================================================
[Timer timed: Elapsed (per call): 0.02 (0.000016), CPU (per call): 0.01 (0.000010), calls: 1000, '***' denotes corrected
line below]
Timer              Elapsed          CPU          Calls        Ela/Call        CPU/Call
SimpleAggChr          9.84         0.36              1         9.84400         0.36000
ClobAggPrc            9.37         0.32              1         9.37400         0.32000
SimpleAggClob         8.25         0.22              1         8.25000         0.22000
(Other)               0.00         0.00              1         0.00000         0.00000
Total                27.47         0.90              4         6.86700         0.22500
13 rows selected.

Similar Messages

  • I've been using iMovie '09 for more than a year and now .MTS files won't upload?

    I've been using iMovie '09 for more than a year and each time I would plug in my SD card (using a card reader) the import box would open and I could select the clips I wanted to work with. Now, suddenly, today the import box won't open. Why??? I literally just used the exact same method three weeks ago and it worked fine. I have not done anything differently. Also, when I go to "file > import from camera" it only shows the built-in camera. What am I doing wrong? And how do I get my files? I do not want to download a converter of any time. I know there has to be a way because it literally just worked three weeks ago so I'm just trying to figure out why it won't work now.

    Unfortunately, you cannot upgrade to Safari 5 or 6 on Mac OSX 10.4.11 and that is what you need to access iCloud (http://support.apple.com/kb/ht4759). I am not sure, but maybe you can install another and newer browser version of Firefox or Chrome to access iCloud.

  • If-function for more than one cell

    Hello friends,
    I am looking for an if-function that asks for more than one cell. EG:
    =If(A2=True;50;0) were A2 is a marker field. In my table A3, A4 and A5 are markerfields as well. How do I add those cells to my my function. Saying: Is any of A2-A5 true, than say 50 else say 0.
    As a second question:
    Is there a function that says: If A2 is true give me 50, if A3 is true gimme 40 ... all in one function!?
    Thanks a lot for helping me !!
    Jimmy

    The answer to both is yes you can perform these using functions that exist in Numbers:
    1) You can use check boxes for the marker cells then use cells in the next column to translate from check boxes to a numeric value:
    e.g. B2 = if(A2=TRUE, 1, 0)
    then sum the cells in B2 - B5 and compare to 0.  if the sum is greater than zero then one of the check boxes is checked:
    2) The question with this request is what if more than one marker is set (again I am assuming you are using check boxes)
    I am assuming the A2 take precedence (that is if the checkbox for A2 is checked that the result will be 50 EVEN if A3 is checked)
    A1 = IF(A2=TRUE, 50, IF(A3=TRUE, 40, 0))

  • Using in clause having more than 4000 chars in a VO.

    Hi Experts,
    JDEV version 11.1.1.5.0
    I have a problem passing a bind variable having length of more than 4000 chars in ADF for use in a IN clause.
    For e.g the query is
    select user_id from employees where user_name in (
    SELECT     column_value
    FROM TABLE (CAST (in_list_char (nvl( 'apple,oranges',user_name) ) AS ChartableType)) A)
    in_list_char is function returning an array of type ChartableType.
    ChartableType is a type
    create or replace TYPE    "CHARTABLETYPE" as table of varchar2(4000);
    It works if the bind value that I pass is of length less than 4000 chars.
    Anything higher it breaks and throws ORA-01460: unimplemented or unreasonable conversion requested.
    Have even tried changing the ChartableType  varchar2 length to 32767..but no luck.
    Any help would be appreciated.

    Hi Timo,
    I am using a in clause as the value that I pass as a bind variable is not stored anywhere in the db for me to have a join or a subselect.
    It's a comma separated string (comma separated user names) for which I would need to check against the employee table to fetch the user_id's .
    An alternative would be to store those values in temp table and have a join.
    But then I was trying to find an alternative , either having a OR clause or UNION dynamically appended to my VO
    Any help is much appreciated.

  • Impossible to send back a CSV file containing more than 8000 chars

    Hello,
    I work on an application using Spring and I try to write a String of around 19000 chars in a CSV file that I send back to the client with the method PrintWriter.write (response.getWriter().write) of the object HttpServletResponse. Here is the code :
    public ModelAndView getViewdomainReport(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // domainString is a string containing around 19000 chars
    String domainString = reportManagementService.getViewdomainReport(domainRows,domain);
    String filename = domain.getDomainNameWithoutBlank()+".csv";
    response.setContentType("text/csv");
    response.getWriter().write(domainString);
    response.setHeader("Content-Disposition", "attachment; filename=\""
                       + filename + "\"");
    return null;
    The following thing is strange : when the String domainString has less than 8000 chars, the file CSV is sent back to the client with the appropriate name and I can open it with EXCEL. When I exceed 8000 chars, I cannot get the response with a CSV format, but the response is directly sent to the browser as a String (domainString) printed directly in the browser page with the URL /getViewdomainReport.htm. That is I exceed the capacity of a sent file with the method write. I think that the fact that it is sent in a CSV format has no importance. It would be the same with a html format or else. It is surely the size of the response which is limited. What can I do ? is it a buffer matter ? how can I get my 19000 chars in my CSV file so I can open it with EXCELL ?
    If you can help me, thank you in advance

    Please don't cross post. As your thread in New to Java has the largest number of replies, please continue in that thread.
    [http://forums.sun.com/thread.jspa?threadID=5338772]
    I'm locking this thread and the one you posted in Java Servlet.
    db

  • My iPhone5 has terrible Network connection. It rarely works at the normal speed-if ever. I usually get 3G or 1x network dozens of times a day. My phone also gets pretty hot when i try to use any data for more than a few minutes.

    My iPhone5 network connection has been terrible for the past week and a half. My phone is no more than a year old so I don't see why it would be a problem with the phone. When I try to use the internet or look for apps or anything like that, anything that uses data really, it takes FOREVER if it even loads! Most of the time it won't even load. My network changes from LTE(which doesn't work well) to 3G(which works even less) and then to 1x(which basically doesn't work at all). This happens dozens of times a day. It's getting quite irritating. I've tried turning my phone off and letting it sit for a while and that does nothing. I'd really prefer NOT to restore my phone. What is the deal??!

    Are you broadcasting your SSID? Sometimes this can cause a problem connecting. Is this Cisco router running any turbo modes or special preparatory protocols.
    There are no know issues with Wi-Fi connectivity except on first connection; and the chance of 2 devices having the exact same issue is very unlikely. This sounds like something to do with your wireless router.
    Have you tried to connect to another Wi-Fi hotspot elsewhere?
    Do you have any 2.4 GHz wireless phones or security system that could interfere with connection?

  • I am having trouble logging into my account, I have been using the system for more than a year. But it seems that certain characters are not appearing when I enter my password especially U,E etc.even enter button is counted as a character. Pls help

    Please help me sort out the problem as soon as possible , I gotta get data from my system urgently

    Which os version are you using? 

  • Purchased "Moneypad app" missing in App Store. I've used that app for more than a year and all my financial records are in it. I have the backup but I need the app. How can a purchased app go missing??? Is that even legal??

    I've used "Moneypad" app to record my financial transaction for over a year and I got an update today. After updating all the icons where misplaced and there were a lot of bugs in the app. The update said "Restore original app icon". So I decided to delete it and reinstall the app but now i couldn't find the application in the itunes store both through my Macbook air and my iphone 5. What do I do now?? how can a purchased app go missing? Is it even legal to delete apurchased app from the itunes store?? What happened to my money and the worst part is my records cant be used in anyother application but "Moneypad". There were 2 version of the app in the store. One was free and the other One was paid. The free app is still there but the paid One is gone!! Please respond to this issue as soon as possible! I need it to record my daily transactions or it would mess up my work a lot! Thankyou.

    I did buy it long back! and now,I downloaded the free version and it requires me to buy it again to make it pro. and NO I dont have a copy of the application with me! I juz have the backup of the app data with me! and "
    MoneyPad√ " is the trial version. The original version which was Rs.220 in India when i got it was named "MoneyPad" without the mathematical symbol. Please is there any way i could get that application back?? I purchased the application and i've got all rights to own it! and what do you mean by "App developers can remove their apps from the store at any time"? So Can I upload some stupid app claiming to be something else and costing around $100 and delete it as soon as someone purchases it??

  • Using "in clause" for more than one collumn

    Hallo,
    for the following statement, I got the error "FEHLER in Zeile 16:
    ORA-00920: Ungultiger relationaler Operator". What is wrong on it?
    SELECT
    'ALTER TABLE ' ||
    c.owner ||
    '.' ||
    c.table_name ||
    ' MODIFY(' ||
    '"' ||
    c.column_name ||
    '"' ||
    c.data_type ||
    '(' ||
    c.data_length*1.3 ||
    FROM
    sys.dba_tab_columns c
    where (owner, table_name, column_name) in
    SELECT 'user1'||', '||'table1'||', '||'collumn3' FROM DUAL UNION ALL
    SELECT 'user2'||', '||'table17'||', '||'collumn23' FROM DUAL
    Thank you for your help!
    Paul

    ... and it does not work! :-(
    # A
    This statement works:
    SELECT
    'ALTER TABLE ' ||
    c.owner ||
    '.' ||
    c.table_name ||
    ' MODIFY(' ||
    '"' ||
    c.column_name ||
    '"' ||
    c.data_type ||
    '(' ||
    round(c.data_length*1.3) ||
    FROM
    sys.dba_tab_columns c
    where (c.owner, c.table_name, c.column_name) IN
    ('SYS', 'GV_$DB_CACHE_ADVICE', 'INST_ID')
    # B
    if I insert the following sub select, it does not work ...
    SQL> SELECT
    2 'ALTER TABLE ' ||
    3 c.owner ||
    4 '.' ||
    5 c.table_name ||
    6 ' MODIFY(' ||
    7 '"' ||
    8 c.column_name ||
    9 '"' ||
    10 c.data_type ||
    11 '(' ||
    12 round(c.data_length*1.3) ||
    13 '));'
    14 FROM
    15 sys.dba_tab_columns c
    16 where (c.owner, c.table_name, c.column_name) IN
    17 (select '('||'''SYS'||''', '''||'GV_$DB_CACHE_ADVICE'||''', '''||'INST_ID'''||')' from dual);
    (select '('||'''SYS'||''', '''||'GV_$DB_CACHE_ADVICE'||''', '''||'INST_ID'''||')' from dual)
    FEHLER in Zeile 17:
    ORA-00947: Anzahl der Werte reicht nicht aus
    # C
    the result of the sub select is the following ....
    select '('||'''SYS'||''', '''||'GV_$DB_CACHE_ADVICE'||''', '''||'INST_ID'''||')' from dual;
    ('SYS', 'GV_$DB_CACHE_ADVICE', 'INST_ID')
    Has any one an idea?
    Paul
    Sorry! I think the last reply was needless!
    Sorry for wasting your time!
    Paul
    Message was edited by:
    talloom_nagar

  • Using Calendar functions on more than one field

    Could someone clarify the date functions of 0Calendar for me?
    We are told that you can only point the calendar functions to one date field in a InfoCube/Query.  I find this extremely limiting, for example, Validity Start Date and Validity End Date within the Contract Management content 0SRCT, we want to be able to view summaries at a day/week/month/quarter/year level on both fields, but we are being told we can only do this for one of the fields, and the other one we would have to create a custom field.  Also does the calendar function apply to a Infocube level or query level, as some of the multi cube (0SR_MC02) have 0CAL_DAY in at least 3 of the DSOs, how do you know which one is referenced in the query?
    Any information on this would be appreciated.
    Thanks.

    The problem is that the DISTINCT|UNIQUE clause does not take a braketted list but applies across all columns.
    SELECT DISTINCT(dummy, dummy) FROM dual;  -- Invalidwill therefore give the same error as
    SELECT (dummy, dummy) FROM dual;  -- InvalidYou can only get away with
    SELECT DISTINCT(dummy) FROM dual;  -- misleadingbecause it is legal to bracket a single expression, like this
    SELECT (dummy) FROM dual;

  • An error ocurred while loading this content! Ive using my ATV for more than 6 months and last week i update the sw and since then i have rented two movies and keep seeing the same message. I have reset the ATV two times without success. Any suggestions?

    I keep getting this message: AN ERROR OCURRED WHILE LOADING THIS CONTENT
    ATV was working fine until i did a version update last week. Since then i have rented two movies and keep getting the same message
    I restarted the ATV - no success
    I reset my wireless - no success
    I reset my ATV - no success
    netflix is working fine since i was able to see a movie there. Youtube was also working fine. I think there should be something wrong with iTunes
    Any ideas?

    I keep getting this message: AN ERROR OCURRED WHILE LOADING THIS CONTENT
    ATV was working fine until i did a version update last week. Since then i have rented two movies and keep getting the same message
    I restarted the ATV - no success
    I reset my wireless - no success
    I reset my ATV - no success
    netflix is working fine since i was able to see a movie there. Youtube was also working fine. I think there should be something wrong with iTunes
    Any ideas?

  • I tried to burn windows 7 Iso using disk utility for more than 3 time with the minimum speed, but all the three times I got error saying "disk burn failed unable to verify"?

    I have tried with three different blank DVDs but all got the same error message. But after I got the error message when I reinsert the DVD I can see the ISO in the DVD. So I went a head with the installation but the installation stops just after it starts. I have even tried burning the disk at 2X speed.

    It sounds like your optical drive may be dirty. The lens probably needs a cleaning. You can go to somewhere like Best Buy and pick up a cleaning kit.

  • I have a licence code for Adobe CS6 Master Collection which I'm using for more  than a year, suddeny I am in trial mode (all programs)  an it seems that this code is not accepted anymore. Help needed!!

    I have a licence code for Adobe CS6 Master Collection which I'm using for more  than a year, suddeny I am in trial mode (all programs)  an it seems that this code is not accepted anymore. Help needed!!

    Chat Now button near the bottom for Activation and Deactivation problems may help
    http://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html

  • Can we use same program ID for more than one RFC scenarios

    Hi experts,
                I am working on a RFC to FILE scenario. I have created one TCP/IP connection in SM59 with a program ID. Can we use this program ID for more than one scenario. I have written code as below
    data: iquote type standard table of ZIQMD initial size 0,
          IPRODUCT type standard table of ZPMS initial size 0,
          wa_quote type ZIQMD,
          wa_PRODUCT type ZPMS.
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER'
      TABLES
        I_QUOTE       = iquote          .
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER' in background task DESTINATION
    'ID4'
      TABLES
        I_QUOTE       = iquote          .
      COMMIT WORK.
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER'
      TABLES
        IPRODUCT       = IPRODUCT          .
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER' in background task DESTINATION
    'ID4'
      TABLES
        IPRODUCT       = IPRODUCT          .
        COMMIT WORK.
    when i am executing the code like this. i am able to send the data to 'Z_CBT_RFC_QUOTEMASTER'  , but iam not getting data  for 'Z_CBT_RFC_PRODUCTMASTER'  interface. ID4 is the connection that i have created in SM59. with program ID as ABCD.
                  Can i use the same connection for all interfaces.Please help in this, if we can use same connection for all interfaces. then how to make changes in XI.
    Thanks in advance.
    Thanks & Regards,
    Poorna.

    Just tried this and I can confirm that my earlier understanding was correct!
    One of my colleagues confused me out and the conclusion is,
    1. You need a separate TCP IP Connection for every interface with a Unique program ID.
    Regards
    Bhavesh

  • My iphoto quites unexpectedly everytime I open it and says closes while using the eOkaoFr.dylib plugin. Does anyone know how to fix this? iphoto won't stay open for more than 1 minute at a time.

    My iphoto quites unexpectedly everytime I open it and says closes while using the eOkaoFr.dylib plugin. Does anyone know how to fix this? iphoto won't stay open for more than 1 minute at a time. Help anyone?

    Is there a crash log? If so post the first 100 or so lines o fit
    Do you know what the ofending plugin is? and where it came from?
    LN

Maybe you are looking for

  • Como identificar no BP o regime de tributação de um fornecedor

    Prezados, Para entregar a obrigação acessória municipal "Nota Carioca" é necessário identificar os pagamentos de serviço feitos no mês para fornecedores optantes pelo simples. O software tributário que utilizamos é o Mastersaf, que por sua vez trata

  • Unable to initialize HDV deck.   Please make sure a deck is connected....

    Ok, this is driving me nuts. I've done this before. I have a Canon HV20. I spent HOURS and HOURS on Sunday (two days ago) capturing 1.5 hours of video (DV, not HD) from my HV20 using iMovie09. Then spent more hours burning a DVD using iDVD09. Results

  • Mac mini to MacBook pro

    I would like to sync the contents of my new mac-mini to my macbook pro. How can I do this "on the cheap"? I see the migration tool doesnt do that... thanks so much... Steve PS-The min is OS 10.5x the Macbook is OS 10.4.11

  • To change the approval limit for Extended attribute PO Value limits

    Hi, We are on SRM 4.0, in PPOMA_BBP for a local purchasing organisation we want to change the approval limit let us say from 100 to 50 but the system is presenting this field as non editable( In stabdard values sub screen) In Extended attribute tab i

  • WHY CAN'T I GET EXTERNAL HARD DRIVE TO IMPORT IN iMOVIE?

    I have linked my computer to an external hard drive to import clips with a firewire cable(the same one I use when I import from my camcorder). iMovie detects the device is plugged in, but is not playing the pictures or sound. Is there a setting I nee