<?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>OraQA &#187; XML</title>
	<atom:link href="http://oraqa.com/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Thu, 09 Dec 2010 04:07:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to select from an alternative table when the table in the From Clause doesn&#8217;t exist in the database</title>
		<link>http://oraqa.com/2010/12/08/how-to-select-from-an-alternative-table-when-the-table-in-the-from-clause-doesnt-exist-in-the-database/</link>
		<comments>http://oraqa.com/2010/12/08/how-to-select-from-an-alternative-table-when-the-table-in-the-from-clause-doesnt-exist-in-the-database/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 04:07:45 +0000</pubDate>
		<dc:creator>Frank Zhou</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://oraqa.com/?p=630</guid>
		<description><![CDATA[The following is an interesting problem posted on an internet website:
select a.id, b.str
from TARGET_TAB a, lookup_tab b WHERE a.id = b.id
If &#8220;TARGET_TAB&#8221; Table doesn&#8217;t exist in the database, then the alternative table &#8220;ALTERNATIVE_TAB&#8221; should be used instead.
select a.id, b.str
from ALTERNATIVE_TAB a, lookup_tab b WHERE  a.id = b.id
Requirement : Solve this problem by using a [...]]]></description>
			<content:encoded><![CDATA[<p>The following is an interesting problem posted on an internet website:</p>
<p>select a.id, b.str<br />
from TARGET_TAB a, lookup_tab b WHERE a.id = b.id</p>
<p>If &#8220;TARGET_TAB&#8221; Table doesn&#8217;t exist in the database, then the alternative table &#8220;ALTERNATIVE_TAB&#8221; should be used instead.</p>
<p>select a.id, b.str<br />
from ALTERNATIVE_TAB a, lookup_tab b WHERE  a.id = b.id</p>
<p>Requirement : Solve this problem by using a single sql query.</p>
<p>create table TARGET_TAB      as select level as id  from dual connect by level &lt;4;<br />
create table ALTERNATIVE_TAB as select level as id  from dual connect by level &lt;6;<br />
create table lookup_tab      as select level as id, chr(64+level) str from dual connect by level &lt;6;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-SQL Solution&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<pre>
WITH XML AS
(SELECT dbms_xmlgen.getxml('SELECT id FROM '||table_name) xml_clob
 FROM user_tables
 WHERE table_name IN
    (SELECT 'TARGET_TAB' FROM dual
      UNION ALL
      SELECT 'ALTERNATIVE_TAB' FROM dual
      WHERE NOT EXISTS (SELECT NULL FROM user_tables WHERE table_name = 'TARGET_TAB')
     )
 ),
 DATA AS
( SELECT ID
  FROM   XML,  XMLTable('ROWSET/ROW'
                         PASSING XMLTYPE(XML.xml_clob)
                         COLUMNS
                         ID NUMBER PATH 'ID')
 )
 SELECT a.ID, str
 FROM DATA a, lookup_tab b
 WHERE a.ID = b.id;

        ID S
---------- -
         1 A
         2 B
         3 C     

drop table target_tab;

Run the same SQL again.

        ID S
---------- -
         1 A
         2 B
         3 C
         4 D
         5 E
</pre>
]]></content:encoded>
			<wfw:commentRss>http://oraqa.com/2010/12/08/how-to-select-from-an-alternative-table-when-the-table-in-the-from-clause-doesnt-exist-in-the-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Generate XML Data from the Database</title>
		<link>http://oraqa.com/2006/04/27/how-to-generate-xml-data-from-the-database/</link>
		<comments>http://oraqa.com/2006/04/27/how-to-generate-xml-data-from-the-database/#comments</comments>
		<pubDate>Thu, 27 Apr 2006 20:01:16 +0000</pubDate>
		<dc:creator>Eddie Awad</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://oraqa.com/2006/04/27/how-to-generate-xml-data-from-the-database/</guid>
		<description><![CDATA[You can  generate XML from the database using: 

  Standard SQL/XML Functions:

XMLELEMENT
XMLATTRIBUTES
XMLFOREST
XMLCONCAT
XMLAGG
XMLPI
XMLCOMMENT
XMLROOT
XMLSERIALIZE
XMLPARSE
            


  Oracle Database SQL Functions:

XMLSEQUENCE
XMLCOLATTVAL
XMLCDATA
            
SYS_XMLGEN
 SYS_XMLAGG
            [...]]]></description>
			<content:encoded><![CDATA[<p>You can  generate XML from the database using: </p>
<ul>
<li>  Standard SQL/XML Functions:
<ul>
<li>XMLELEMENT</li>
<li>XMLATTRIBUTES</li>
<li>XMLFOREST</li>
<li>XMLCONCAT</li>
<li>XMLAGG</li>
<li>XMLPI</li>
<li>XMLCOMMENT</li>
<li>XMLROOT</li>
<li>XMLSERIALIZE</li>
<li>XMLPARSE
            </li>
</ul>
</li>
<li>  Oracle Database SQL Functions:
<ul>
<li>XMLSEQUENCE</li>
<li>XMLCOLATTVAL</li>
<li>XMLCDATA
            </li>
<li>SYS_XMLGEN</li>
<li> SYS_XMLAGG
            </li>
</ul>
</li>
<li>DBMS_XMLGEN</li>
<li> XSQL Pages Publishing Framework</li>
<li> XML SQL Utility (XSU)</li>
<li>DBURIType</li>
</ul>
<p>Some of the options above may not be available in versions of the Oracle database earlier than 10g Release 2 (10.2).</p>
<p>For more details on each of the above options check out:</p>
<ul>
<li><a href="http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb13gen.htm">Oracle XML DB Developer&#8217;s Guide 10g Release 2 (10.2) &#8211; Chapter 16</a> </li>
<li><a href="http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96620/xdb12gen.htm">Oracle9i XML Database Developer&#8217;s Guide &#8211; Oracle XML DB Release 2 (9.2) &#8211; Chapter 10</a></li>
</ul>
<p>Related links:</p>
<ul>
<li><a href="http://awads.net/wp/2005/12/19/producing-xml-from-sql-using-cursor-expressions/">Producing XML from SQL using cursor expressions</a></li>
<li><a href="http://blogs.ittoolbox.com/oracle/guide/archives/004410.asp">XML in the Database: A Brief Overview</a> </li>
<li><a href="http://blogs.ittoolbox.com/oracle/guide/archives/008716.asp">Get the XML out of your database</a></li>
<li><a href="http://blogs.ittoolbox.com/oracle/guide/archives/006917.asp">XE, XML and WebDAV &#8211; Access your XML data in Oracle XE</a></li>
<li><a href="http://blogs.ittoolbox.com/oracle/guide/archives/006547.asp">XML and OO in Oracle, A Scenario</a></li>
</ul>
<p>If you have any additional XML resources, please add them in the comments below. </p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://oraqa.com/2006/04/27/how-to-generate-xml-data-from-the-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

