<?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"
	>
<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>
	<pubDate>Mon, 08 Sep 2008 17:22:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<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-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>[&#8230;] Producing XML from SQL using cursor expressions [&#8230;]</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-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>[&#8230;] 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. [&#8230;]</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-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'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 :-).<br />
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><br />
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-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>Aino, this is great, thanks. I ran your example above for department id 20 and 110 and got the following output:

    &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;

&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>
<p>    <company><br />
        <department><br />
            <name>Marketing</name><br />
            <emps><br />
                <employee id = "201"><br />
                    <first_name>Michael</first_name><br />
                </employee><br />
                <employee id = "202"><br />
                    <first_name>Pat</first_name><br />
                </employee><br />
            </emps><br />
        </department><br />
        <department><br />
            <name>Accounting</name><br />
            <emps><br />
                <employee id = "205"><br />
                    <first_name>Shelley</first_name><br />
                </employee><br />
                <employee id = "206"><br />
                    <first_name>William</first_name><br />
                </employee><br />
            </emps><br />
        </department><br />
    </company></p>
<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-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-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>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;pre&gt;
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
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Nice example, good thinking, I remember having this problem in the early Oracle XML days.<br />
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>
