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

  • Home
  • SEARCH
  • 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 118095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:26:26+00:00 2026-05-11T03:26:26+00:00

I have a query that I am generating the XML from in Oracle using

  • 0

I have a query that I am generating the XML from in Oracle using the DBMS_XMLGEN package.

As an example, I am using a cursor as follows:

SELECT    A.NAME primaryName,    (CURSOR(SELECT B.NAME AS NAME FROM B WHERE B.ID=A.ID)) SYNONYMS FROM   A  

I have a query context, qtx, and set the query to the above for that context. Calling:

result := DBMS_XMLGEN.getXML(qryCtx); 

gets me almost where I want to be, from the viewpoint of the generated XML:

<PRIMARYNAME>Main Name</PRIMARYNAME>   <SYNONYMS>    <SYNONYMS_ROW>     <NAME>Synonym1</NAME>    </SYNONYMS_ROW>    <SYNONYMS_ROW>     <NAME>Synonym2</NAME>    </SYNONYMS_ROW>   </SYNONYMS> 

What I would really like to do is suppress the SYNONYMS_ROW tag. I’ve also tried a (CAST(MULTISET( <query>) and have similar results.

I know I could do a CLOB search and replace, but it seem like there should be a slightly easier or better engineered approach (ie, should I define the desired xsd and use that somehow?). I could also do a full stored procedure and build the tags as needed on the fly using cursors, but it would be nice to have a single SQL statement to use instead. Thanks for any suggestions

Thanks Nick – it turned out that the easiest way to solve the issue I describe was to use the XMLAGG function and generate my XML result slightly differently.

select    XMLELEMENT('primaryName',A.Name),    xmlelement('synonyms',        (SELECT XMLAGG(XMLELEMENT('name',b.name) ) from b         where b.id=a.id and b.type='S') ) from    A 
  • 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. 2026-05-11T03:26:26+00:00Added an answer on May 11, 2026 at 3:26 am

    You’ll need to drop down to PL/SQL where you have more control over the dbms_xmlgen package. For instance, here is how you can change the behavior of the row tags it sets.

    declare qryctx DBMS_XMLGEN.ctxhandle; results xmltype; begin    qryctx := dbms_xmlgen.newcontext('select foo from bar where id = my_id');   dbms_xmlgen.SETBINDVALUE(qryctx,'my_id',id);     dbms_xmlgen.setRowTag(qryCtx,NULL);     dbms_xmlgen.setRowSetTag(qryCtx,NULL);   results := dbms_xmlgen.getxmltype(qryctx);   dbms_xmlgen.closecontext(qryctx);   return results; end; 

    This package will allow you not only to change the row tag, but also the tag that goes around all the rows. In the above example, I suppressed the row tag by passing NULL as the second arguement into the dbms_xmlgen.setRowTag call. I hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 189k
  • Answers 189k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It creates the file in the current directory, and as… May 12, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer One possibility is that you need to install the MS… May 12, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer You may take a look at this thread. May 12, 2026 at 5:47 pm

Related Questions

I'm playing around at the start of a personal project in C# and MySQL.
Working with a SqlCommand in C# I've created a query that contains a IN
NOTE: the original question is moot but scan to the bottom for something relevant.
I have recently written an application(vb.net) that stores and allows searching for old council

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.