<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Producing XML from SQL using cursor expressions</title>
	<atom:link href="http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/</link>
	<description>News, views, tips and tricks on Oracle and other fun stuff</description>
	<lastBuildDate>Thu, 18 Mar 2010 16:44:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: OraQA &#187; Blog Archive &#187; How to Generate XML Data from the Database</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-5033</link>
		<dc:creator>OraQA &#187; Blog Archive &#187; How to Generate XML Data from the Database</dc:creator>
		<pubDate>Thu, 27 Apr 2006 20:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-5033</guid>
		<description>&lt;p&gt;[...] Producing XML from SQL using cursor expressions [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] Producing XML from SQL using cursor expressions [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: IT-eye Weblog &#187; XML queries and cursor expressions</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-488</link>
		<dc:creator>IT-eye Weblog &#187; XML queries and cursor expressions</dc:creator>
		<pubDate>Tue, 20 Dec 2005 08:13:56 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-488</guid>
		<description>&lt;p&gt;[...] Eddie Awad has an interesting post on generating xml using cursor expressions: Producing XML from SQL using cursor expressions. Be sure to also read Aino&#8217;s comment, where he shows how you can achieve the same thing but using the xmlelement and xmlagg functions. [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] Eddie Awad has an interesting post on generating xml using cursor expressions: Producing XML from SQL using cursor expressions. Be sure to also read Aino&#8217;s comment, where he shows how you can achieve the same thing but using the xmlelement and xmlagg functions. [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Aino Andriessen</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-486</link>
		<dc:creator>Aino Andriessen</dc:creator>
		<pubDate>Mon, 19 Dec 2005 17:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-486</guid>
		<description>&lt;p&gt;I think it&#039;s available for 9iR2 and up. By the way, this is part of the SQL2003 standard :-).
Check out: http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb13gen.htm#g1047191
As of 10gR2 you can also use XQuery, but I do not have any experince with that. My first impression was that I understand SQLXML better.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s available for 9iR2 and up. By the way, this is part of the SQL2003 standard <img src='http://awads.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .
Check out: <a href="http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb13gen.htm#g1047191" rel="nofollow">http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb13gen.htm#g1047191</a>
As of 10gR2 you can also use XQuery, but I do not have any experince with that. My first impression was that I understand SQLXML better.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eddie Awad</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-485</link>
		<dc:creator>Eddie Awad</dc:creator>
		<pubDate>Mon, 19 Dec 2005 17:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-485</guid>
		<description>&lt;p&gt;Aino, this is great, thanks. I ran your example above for department id 20 and 110 and got the following output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;company&gt;
    &lt;department&gt;
        &lt;name&gt;Marketing&lt;/name&gt;
        &lt;emps&gt;
            &lt;employee id = &quot;201&quot;&gt;
                &lt;first_name&gt;Michael&lt;/first_name&gt;
            &lt;/employee&gt;
            &lt;employee id = &quot;202&quot;&gt;
                &lt;first_name&gt;Pat&lt;/first_name&gt;
            &lt;/employee&gt;
        &lt;/emps&gt;
    &lt;/department&gt;
    &lt;department&gt;
        &lt;name&gt;Accounting&lt;/name&gt;
        &lt;emps&gt;
            &lt;employee id = &quot;205&quot;&gt;
                &lt;first_name&gt;Shelley&lt;/first_name&gt;
            &lt;/employee&gt;
            &lt;employee id = &quot;206&quot;&gt;
                &lt;first_name&gt;William&lt;/first_name&gt;
            &lt;/employee&gt;
        &lt;/emps&gt;
    &lt;/department&gt;
&lt;/company&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I believe that &lt;code&gt;SQLXML&lt;/code&gt; should work in 9i and 10g but not 8i.&lt;/p&gt;

&lt;p&gt;Oh! by the way, the backslashes are added by Markdown. I tried, but I could not get rid of them. Sometimes Markdown is bad :(&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Aino, this is great, thanks. I ran your example above for department id 20 and 110 and got the following output:</p>

<pre><code>&lt;company&gt;
    &lt;department&gt;
        &lt;name&gt;Marketing&lt;/name&gt;
        &lt;emps&gt;
            &lt;employee id = "201"&gt;
                &lt;first_name&gt;Michael&lt;/first_name&gt;
            &lt;/employee&gt;
            &lt;employee id = "202"&gt;
                &lt;first_name&gt;Pat&lt;/first_name&gt;
            &lt;/employee&gt;
        &lt;/emps&gt;
    &lt;/department&gt;
    &lt;department&gt;
        &lt;name&gt;Accounting&lt;/name&gt;
        &lt;emps&gt;
            &lt;employee id = "205"&gt;
                &lt;first_name&gt;Shelley&lt;/first_name&gt;
            &lt;/employee&gt;
            &lt;employee id = "206"&gt;
                &lt;first_name&gt;William&lt;/first_name&gt;
            &lt;/employee&gt;
        &lt;/emps&gt;
    &lt;/department&gt;
&lt;/company&gt;
</code></pre>

<p>I believe that <code>SQLXML</code> should work in 9i and 10g but not 8i.</p>

<p>Oh! by the way, the backslashes are added by Markdown. I tried, but I could not get rid of them. Sometimes Markdown is bad <img src='http://awads.net/wp/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Aino Andriessen</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-484</link>
		<dc:creator>Aino Andriessen</dc:creator>
		<pubDate>Mon, 19 Dec 2005 15:12:32 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-484</guid>
		<description>&lt;p&gt;Sorry, but the backslashes in my previous comment should not be there.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Sorry, but the backslashes in my previous comment should not be there.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Aino Andriessen</title>
		<link>http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/comment-page-1/#comment-483</link>
		<dc:creator>Aino Andriessen</dc:creator>
		<pubDate>Mon, 19 Dec 2005 15:09:59 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/?p=182#comment-483</guid>
		<description>&lt;p&gt;Nice example, good thinking, I remember having this problem in the early Oracle XML days.
With recent database versions however I would suggest to use SQLXML. It has more options, is more flexible and (in my opinion) easier. Your example would be something like:&lt;/p&gt;

&lt;pre&gt;
select  xmlelement (&quot;company&quot;,
           xmlagg (xmlelement (&quot;department&quot;,
           xmlelement (&quot;name&quot;, dept.department_name),
           xmlelement (&quot;emps&quot;,
             (select xmlagg (xmlelement (&quot;employee&quot;,
               xmlattributes (emp.employee_id as &quot;id&quot;),
               xmlforest (emp.first_name as &quot;first_name&quot;)))
             from    employees emp
             where emp.department_id = dept.department_id)
                       )
                   )
           )
       ) xml
from departments dept
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Nice example, good thinking, I remember having this problem in the early Oracle XML days.
With recent database versions however I would suggest to use SQLXML. It has more options, is more flexible and (in my opinion) easier. Your example would be something like:</p>

<pre>
select  xmlelement ("company",
           xmlagg (xmlelement ("department",
           xmlelement ("name", dept.department_name),
           xmlelement ("emps",
             (select xmlagg (xmlelement ("employee",
               xmlattributes (emp.employee_id as "id"),
               xmlforest (emp.first_name as "first_name")))
             from    employees emp
             where emp.department_id = dept.department_id)
                       )
                   )
           )
       ) xml
from departments dept
</pre>]]></content:encoded>
	</item>
</channel>
</rss>
