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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:55:05+00:00 2026-06-14T01:55:05+00:00

I am facing a problem using XMLAGG in sql. I have a table with

  • 0

I am facing a problem using XMLAGG in sql.

I have a table with multiple records which can be repeated. the Table contains Customer Addresses and Customer Name.

Create Table cust_data(
    cust_name varchar2(30),
    cust_addr_line1 varchar2(300),
    cust_addr_line2 varchar2(300),
    cust_addr_line3 varchar2(300),
    cust_addr_type varchar2(3));

The table may contain multiple records for a Single Customer Name and Different Address Types.

Also, a single customer may have multiple addresses of the same type also.

so a customer may have addresses like

cust1 address1 curr_address
cust1 address2 old_address
cust1 address3 old_address
cust1 address4 old_address
cust2 address5 curr_address
cust2 address6 old_address

I have a select where i want to take out all the customer names with old_addresses in a comma separated format.

using the same i used the following sql

 select XMLAGG(XMLELEMENT(E, cust_name || ',')).EXTRACT('//text()')
 from cust_data where cust_addr_type ='old_address';

I get the following output:

cust1,cust1,cust1,cust2,

how do get the output as

cust1,cust2

Please help.

Edit#1:

The other tables can be taken like this:

Create Table cust_info(
    cust_name varchar2(30),
    Cust_account varchar2(300),
    cust_amount_paid varchar2(300),
    cust_amount_pend varchar2(300),
    cust_payment_type varchar2(300));

Create Table payment_master_info(
    pmnt_type varchar2(30),
    pmnt_desc varchar2(300),
    pmnt_rate varchar2(300),
    pmnt_tenure varchar2(300));

The query is like this:

SELECT XMLAGG(XMLELEMENT(E, CUST_NAME || ',')) .EXTRACT('//text()'),
             CD.CUST_ADDR_LINE1,
             CD.CUST_ADDR_LINE2,
             CD.CUST_ADDR_LINE3,
             CI.CUST_AMOUNT_PAID,
             CI.CUST_AMOUNT_PEND,
             CI.CUST_ACCOUNT
    FROM CUST_INFO CI, PAYMENT_MASTER_INFO PM, CUST_DATA CD
 WHERE CD.CUST_NAME = CI.CUST_NAME
     AND CI.CUST_PAYMENT_TYPE = PM.PMNT_TYPE
     AND CUST_ADDR_TYPE = 'old_address';

Now the data in this huge. the data in the pmnt_type ranges from 10000-15000 data
and in other tables it ranges from 2100000-5000000

If I apply inner queries for distinct data, the performance drops exponentially.

is there any other way?

Edit#2: Also while using this inner query, during executing, i getting an ORA-19011(: Character string buffer too small.) error. can there be any reason why…??

  • 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-14T01:55:06+00:00Added an answer on June 14, 2026 at 1:55 am

    You can use a DISTINCT in an inner query:

    SQL> select XMLAGG(XMLELEMENT(E, cust_name || ',')).EXTRACT('//text()')
      2   from (SELECT distinct cust_name, cust_addr_type FROM cust_data)
      3  where cust_addr_type ='old_address';
    
    XMLAGG(XMLELEMENT
    -----------------
    cust1,cust2,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been facing so many problem using the anonymous class like I can't
I'm facing a problem with plotting data using the CorePlot framework. I have integrated
I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
I'm currently facing in problem using Core Data. I have two entities A and
I have developed a game using andengine I am facing a problem when using
I am facing a small problem using silver light . I have a RadGridView,
I'm facing a problem when using tapestry 5.2.0 : using multiple times a component
So, I have been facing a problem with using subprocess for a python app
I am facing a problem while using Select statement where I have a column
I am facing problem regarding uploading doc file using php. I can successfully upload

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.