Solved

Oracle 11i  pl/sql

Posted on 2011-09-28
4
284 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
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
Comment Utility
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
Comment Utility
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 76

Accepted Solution

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


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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now