Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Function returning comma sepparated values (istead of crosstab)

Posted on 2008-06-11
2
Medium Priority
?
728 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
[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 Comments
 
LVL 15

Accepted Solution

by:
ishando earned 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

610 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