Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:02:33+00:00 2026-06-03T07:02:33+00:00

I’m using SYS_CONNECT_BY_PATH to do string aggregation. The general shape of the query is

  • 0

I’m using SYS_CONNECT_BY_PATH to do string aggregation. The general shape of the query is something like this:

select /*a bunch of fields unrelated to the problem*/,
--Use SYS_CONNECT_BY_PATH to glue together all the chunks of XML. 
--The XSL header and footer are prepended and appended here.
 , XMLType(to_clob('<?xml version="1.0"?><!-- begining of XSL file -->,'<!-- Next Section -->'))||'</xsl:stylesheet>')) AS XSL
from (
  select /*a bunch of fields unrelated to the problem*/
    case when x = 1 then to_clob('
    /*a bunch of XSL*/
     <xsl:text>'||subq.new_c_value||'</xsl:text>
    /*a whole bunch more xsl*/')
    else
     to_clob('/*a bunch of different XSL*/             
     <xsl:text>'||subq.new_f_value||'</xsl:text>
    /*a whole bunch more xsl*/')
    end as xsl,
  --curr and prev are to help with using sys_connect_by_path do string aggregation.
    rownum AS curr,
    rownum -1 AS prev
  from (Select /* details of subq not relevant */ ) as subq
)
CONNECT BY prev = PRIOR curr 
START WITH curr = 1;

Basically, I’m running a query to generate XSL that is used to correct XML files. I’m using sys_connect_by_path to combine the strings together into one single chunk, which is easier than copying and pasting many values from many rows. I can’t use any custom string aggregate functions because this query runs on a production database where I can’t just go and create functions as I want.

The problem is that running my query will return:

ORA-01489: result of string concatenation is too long
01489. 00000 -  "result of string concatenation is too long"
*Cause:    String concatenation result is more than the maximum size.
*Action:   Make sure that the result is less than the maximum size.

…in cases where there is too much data. As you can see, I’ve been applying the to_clob() function to anywhere I think it might help, but it doesn’t seem to have made much difference. Are there any other ways to handle this besides resorting to PL/SQL? I’d prefer to keep this as a query because the result of this query is exported to a report template which shows a number of useful pieces of information side-by-side with the XSL. It would be nice to be able to do all of this in one single step rather than in several steps.

(Oracle 10g)


Eventually, I found this page:

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

about string aggregation techniques in Oracle. I suspect the only ones that will work in my situation are the XML method and the Model methods. I couldn’t get the model methods to work quite right so I just went with the XML method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:02:35+00:00Added an answer on June 3, 2026 at 7:02 am
    select
        xmlroot
        (
            xmlelement
            (
                "xsl:stylesheet"
                ,XMLAttributes
                (
                    '1.0' as version
                    ,'http://www.w3.org/1999/XSL/Transform' as "xmlns:xsl"
                    ,'http://test' as "xmlns:ns0"
                )
                ,(
                    xmlagg(xmlelement("xsl:text", val))
                )
            )
            ,version '1.0'
        )
    from
    (
        --Test >4000 characters
        select 1 id, cast(rpad('a',4000,'a') as varchar2(4000)) val from dual union all
        select 1 id, cast(rpad('b',4000,'b') as varchar2(4000)) val from dual union all
        select 1 id, cast(rpad('c',4000,'c') as varchar2(4000)) val from dual union all
        select 1 id, cast(rpad('d',4000,'d') as varchar2(4000)) val from dual
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.