0

My table has the below data

Username Groupname
-------- ---------------
A        MAXADMIN
A        BUYER
B        PURCHASEMANAGER
B        FINANCECLERK

Output should be like below

Username Groupname 
-------- ----------------------------
A        MAXADMIN,BUYER
B        PURCHASEMANAGER,FINANCECLERK

I get an error ORA-19011: character string buffer too small. Thanks in advance

  select maxuser.userid,
         person.displayname,
         maxuser.status,
         sod_Report.severity,
         sod_Report.scenario,
         RTRIM (XMLAGG (XMLELEMENT (e, groupuser.groupname || ',')).EXTRACT ('//text()'),',') groupname
    from maxuser,
         person,
         groupuser,
         sod_report
   where    maxuser.userid=person.personid
        and groupuser.userid = maxuser.userid
        and sod_report.userid= maxuser.userid
group by maxuser.userid,
         person.displayname,
         maxuser.status,
         sod_Report.severity,
         sod_Report.scenario
3
  • 1
    Who knows? Did you run an explain plan? Commented Dec 2, 2016 at 5:32
  • 1
    Have a look at LISTAGG. Maybe it is not necessary to generate a XML out from a string and then extract string again from this XML. Commented Dec 2, 2016 at 6:55
  • LISTAGG did worked, thanks a lot! Commented Dec 2, 2016 at 10:38

2 Answers 2

1

The error message is self-descriptive.

19011, 00000, "Character string buffer too small"

Cause: The string result asked for is too big to return back

Action: Get the result as a lob instead

You need to use the DBMS_LOB package to retrieve an XMLTYPE data table. Here is an example which explains how to get the result as LOB. ORA-19011: Character string buffer too small

Sign up to request clarification or add additional context in comments.

Comments

1

we can use following function if we need to use more than 4000 characters -

select maxuser.userid,
         person.displayname,
         maxuser.status,
         sod_Report.severity,
         sod_Report.scenario,

         RTRIM (XMLAGG (XMLELEMENT (e, groupuser.groupname || ',')).EXTRACT ('//text()').getClobVal(),',') groupname

.....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.