Solved

Oracle 11i  pl/sql

Posted on 2011-09-28
4
289 Views
Last Modified: 2012-08-13
Hello,

I need to have a result set that is pipe separated - Is this something that I can write just in a query or will I need to actually loop through the result set and create it.
For example results are:
1
2
3
I want only one return  that looks like this:  1 || 2 || 3
0
Comment
Question by:Mosquitoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36719060
Try this:

http://www.experts-exchange.com/Database/Oracle/Q_24914739.html?#a25864822

SELECT
       RTRIM(
           EXTRACT(XMLAGG(XMLELEMENT("s", yourtable.column3 || '||')), '/s/text()').getstringval(),
           '||'
       )
           column3
FROM yourtable
;
0
 

Author Comment

by:Mosquitoe
ID: 36719119
I keep getting an error on this (I had tried to use the listagg function as well - but same error)  Keeps telling me I am missing left parenthesis but I must be blind because I cannots ee what i am missing:

SELECT
       RTRIM(
           EXTRACT(XMLAGG(XMLELEMENT("s", dossier_waste_packaging dwp.dwp.packaging_types || '||')), '/s/text()').getstringval(),
           '||'
       )
           dwp.packaging_types
FROM dossier_waste_packaging dwp
      WHERE dwp.dos_hwmd_sys_entered_yr = 10
      AND dwp.dossier_identifier = 325
      AND dwp.dossier_type_code = 'EXP';
0
 

Author Comment

by:Mosquitoe
ID: 36719130
I tried this as well:

SELECT DISTINCT LISTAGG(dwp.packaging_types, '||') WITHIN GROUP AS PackagingList
      FROM dossier_waste_packaging dwp
      WHERE dwp.dos_hwmd_sys_entered_yr = 10
      AND dwp.dossier_identifier = 325
      AND dwp.dossier_type_code = 'EXP
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 125 total points
ID: 36719174
I keep forgetting about listagg.


Try this:
...
LISTAGG(dwp.packaging_types, '||') WITHIN GROUP (order by packaging_types) AS PackagingList
...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database Design Dilemma 6 71
update using pipeline function 3 46
oracle forms question 9 40
Query for non-UTF8 characters in a column in Oracle 11 39
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question