Solved

Function returning comma sepparated values (istead of crosstab)

Posted on 2008-06-11
2
711 Views
Last Modified: 2013-12-19
Hi.

Would you please give me a workbale sample of the function which can simulate crosstab (pivot).

I need to send two parameters (group_id, type_id) to this function from the view and this function should return the list of comma sepparated values of that type_id.

So if there are three records with type_id values 'a', 'b', 'c' I need to convert them in one text field like 'a, b, c' from the view (query).

Thanks.
0
Comment
Question by:GoodName
2 Comments
 
LVL 15

Accepted Solution

by:
ishando earned 500 total points
ID: 21765739
Something like this should do it:
create or replace function myCommaList (in_gid in integer, in_tid in integer)

  return varchar2

is

  rsetTab dbms_utility.uncl_Array;

  tablen  binary_integer;

  list    varchar2(4000);

  

begin

  select val bulk collect into rsetTab

  from table1

  where group_id = in_gid

  and type_id = in_tid;

  

  dbms_utility.table_to_comma(rsetTab, tablen, list);

  

  return list;

end myCommaList ;

/

Open in new window

0
 

Author Closing Comment

by:GoodName
ID: 31466406
Thanks for the help!
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.

Question has a verified solution.

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

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…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

911 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

16 Experts available now in Live!

Get 1:1 Help Now