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 8650071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:43:33+00:00 2026-06-12T13:43:33+00:00

I need something way bigger than varchar2(2000) to be able to print my generated

  • 0

I need something way bigger than varchar2(2000) to be able to print my generated XML. Either recommend a better approach than dbms_output.put_line(x) or recommend a different data type to store the result and then print it. I am an Oracle newbie and full-time job is UI development.

declare
    v_ctx dbms_xmlgen.ctxHandle;
    x varchar2(2000); -- I need something bigger than varchar2(2000)
begin
    v_ctx := DBMS_XMLGen.newContext('
        select
            baz as "Baz"
        from schema.table_with_10000_rows');
    DBMS_XMLGen.setRowsetTag(v_ctx, 'Foo');
    DBMS_XMLGen.setRowTag(v_ctx, 'Bar');
    x := dbms_xmlgen.getxml(v_ctx);
    dbms_output.put_line(x);
end;
  • 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-12T13:43:34+00:00Added an answer on June 12, 2026 at 1:43 pm

    You need to use a CLOB if you have more than 4000 characters, and that’s the data type that getxml returns. This question seems to be approaching the same issue, and shows a simple way to loop through and print in chunks, though it has a flaw – it should be using dbms_output.put() instead of put_line (edit: maybe with a terminal dbms_output.new_line after the loop; untested I’m afraid).

    If you’re doing this in SQL*Plus you can avoid dbms_output altogether using a client bind variable:

    var x clob;
    
    declare
        v_ctx dbms_xmlgen.ctxHandle;
    begin
        v_ctx := DBMS_XMLGen.newContext('
            select table_name as "Baz"
            from all_tables');
        DBMS_XMLGen.setRowsetTag(v_ctx, 'Foo');
        DBMS_XMLGen.setRowTag(v_ctx, 'Bar');
        :x := dbms_xmlgen.getxml(v_ctx);
    end;
    /
    
    print x
    

    x is declared outside the PL/SQL block, and used withing it as a bind variable – note the colon in the assignment, :x := ....

    X
    --------------------------------------------------------------------------------
    <?xml version="1.0"?>
    <Foo>
     <Bar>
      <Baz>DUAL</Baz>
     </Bar>
     <Bar>
      <Baz>SYSTE
    

    By default you’ll probably only see the start of the XML; you’ll need to set long <some big number> to see it all, and (as of 11g) you’re restricted to 2GB. (I imagine you’ll also want to set feedback and headings off, and maybe longchunk).


    I’d question why you’re printing it to screen like this though, rather than storing in a table. If the ultimate goal is to get it in a file, utl_file might be more appropriate; something like this maybe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally, we get first value that way: $(#color option:first).val() But I need something like
I need a robust way of getting system uptime, and ended up using something
I'm trying to make something similar to an array. I need to be able
I need something to get the hard link count from a file in a
I need something simple like date , but in seconds since 1970 instead of
I need something like make i.e. dependencies + executing shell commands where failing command
I need something simple; I have page where a user clicks an author to
I need something like this http://jonraasch.com/blog/a-simple-jquery-slideshow but w/o the absolute positioning. Is it possible?
I need something like a temporary in-memory key-value store. I know there are solutions
I think I need something akin to a rails eager loaded query with a

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.