<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bigjim-network &#187; group by</title>
	<atom:link href="http://bigjim-network.be/tag/group-by/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigjim-network.be</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 06:32:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MySQL group_contat in ORACLE</title>
		<link>http://bigjim-network.be/2009/04/02/mysql-group_contat-in-oracle/</link>
		<comments>http://bigjim-network.be/2009/04/02/mysql-group_contat-in-oracle/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 11:39:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[oracle]]></category>
		<category><![CDATA[group by]]></category>
		<category><![CDATA[group_concat]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://bigjim-network.be/?p=33</guid>
		<description><![CDATA[Here is a way to add the group_concat function to ORACLE. After that you&#8217;ll be able to do just like in MySQL. first you&#8217;ll need to create a new object type: create or replace TYPE t_string_agg AS OBJECT ( g_string VARCHAR2(32767), STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg) RETURN NUMBER, MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a way to add the group_concat function to ORACLE. After that you&#8217;ll be able to do just like in MySQL.</p>
<p>first you&#8217;ll need to create a new object type:</p>
<p><code><br />
create or replace TYPE t_string_agg AS OBJECT<br />
(<br />
  g_string  VARCHAR2(32767),</p>
<p>  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)<br />
    RETURN NUMBER,</p>
<p>  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,<br />
                                       value  IN      VARCHAR2 )<br />
     RETURN NUMBER,</p>
<p>  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,<br />
                                         returnValue  OUT  VARCHAR2,<br />
                                         flags        IN   NUMBER)<br />
    RETURN NUMBER,</p>
<p>  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,<br />
                                     ctx2  IN      t_string_agg)<br />
    RETURN NUMBER<br />
);<br />
</code></p>
<p>then create a function using the newly created type :</p>
<p><code><br />
create or replace FUNCTION tring_concat (p_input VARCHAR2)<br />
RETURN VARCHAR2<br />
PARALLEL_ENABLE AGGREGATE USING t_string_agg;<br />
</code></p>
<p>now try it with SCOTT&#8217;s schema</p>
<p><code><br />
COLUMN employees FORMAT A50</p>
<p>SELECT deptno, group_concat(ename) AS employees<br />
FROM   emp<br />
GROUP BY deptno;</p>
<p>    DEPTNO EMPLOYEES<br />
---------- --------------------------------------------------<br />
        10 CLARK,KING,MILLER<br />
        20 SMITH,FORD,ADAMS,SCOTT,JONES<br />
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD</p>
<p>3 rows selected.<br />
</code></p>
<p>that could be quite useful to add this function to the SYS schema and then create a public synonym. this way the function will be available to any user of the database.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigjim-network.be/2009/04/02/mysql-group_contat-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
