<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>gudangberas</title>
	<atom:link href="http://gudangberas.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gudangberas.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 16 Sep 2011 20:05:14 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gudangberas.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>gudangberas</title>
		<link>http://gudangberas.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gudangberas.wordpress.com/osd.xml" title="gudangberas" />
	<atom:link rel='hub' href='http://gudangberas.wordpress.com/?pushpress=hub'/>
		<item>
		<title>What is OSP</title>
		<link>http://gudangberas.wordpress.com/2006/10/10/what-is-osp/</link>
		<comments>http://gudangberas.wordpress.com/2006/10/10/what-is-osp/#comments</comments>
		<pubDate>Tue, 10 Oct 2006 01:30:19 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://gudangberas.wordpress.com/2006/10/10/what-is-osp/</guid>
		<description><![CDATA[OSP is VoIP peering protocol and is the international standard for Inter-Domain pricing, authorization and usage exchange of IP communications. The OSP standard is defined by TISPAN of the European Telecommunications Standards Institute (ETSI) www.etsi.org. The OSP standard is officially known as ETSI Technical Specification 101 321. Version 1.4.2 of this standard was ratified in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=25&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">OSP is VoIP peering protocol and    is the international standard for    Inter-Domain pricing, authorization and usage exchange of IP communications.     The OSP standard is defined by TISPAN of the European    Telecommunications Standards Institute (ETSI) <a href="http://www.etsi.org/">   www.etsi.org</a>.  The OSP standard is officially known as ETSI Technical    Specification 101 321.  Version 1.4.2 of this standard was ratified in    December 1998.  Version 4.1.1 of the OSP standard was ratified in    November 2003 and may be downloaded here,   <a href="http://www.transnexus.com/OSP%20Toolkit/ts_101321v040101p.pdf" title="OSP Standard V2.1.1">ETSI    TS 101 321 V4.1.1 (2000-11)</a>.   </font></p>
<p class="MsoBodyText" style="margin-bottom:6px;margin-top:15px;"><font face="Arial"><strong>   <font color="#000080" size="4">Benefits</font></strong> </font></p>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">The major benefit of OSP for VoIP carriers is it provides a single, highly secure    mechanism for managing diverse VoIP networks.  OSP provides a common    interface between VoIP networks and the operations and billing support systems    (OSS/BSS) used to manage VoIP networks.  By using a global VoIP to OSS/BSS    interface, carriers are now enabled to build and manage multi-vendor,    multi-protocol networks without impacting their central routing and billing    operations.  The benefits are greater flexibility, vendor independence    and lower operating costs.</font></p>
<p class="MsoBodyText" style="margin-top:15px;margin-bottom:0;"><strong>   <font color="#000080" face="Arial" size="4">Features</font></strong></p>
<ul>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">Common peering    mechanism for diverse VoIP networks.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">Digitally    signed peering tokens enable secure, ubiquitous peer to peer communications</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">Interdomain access control much more secure and    scalable than IP access lists.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">Common,    standard Call Detail Record (CDR) for diverse VoIP networks.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">Real time    collection of CDRs from both source and destination networks.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">CDR collection    can be encrypted using SSL ensuring secure data collection.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">High CDR    integrity minimizes settlement disputes.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">OSP messages    are XML based which are easy to read, manipulate and extend.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:0;"><font face="Arial" size="2">Supports both    H.323 networks, SIP networks and can support other IP transaction models.</font></p>
</li>
<li>
<p class="MsoBodyText" style="margin-top:0;"><font face="Arial" size="2">Broad vendor    support.</font></p>
</li>
</ul>
<p class="MsoBodyText" style="margin-bottom:0;"><strong>   <font color="#000080" face="Arial" size="4">Overview of OSP</font></strong></p>
<p class="MsoBodyText" style="margin-top:0;"><font face="Arial" size="2">The OSP    standard defines fourteen messages which can be used to convey peering    authorization and capabilities.  This document focuses on the six    messages most commonly used to manage VoIP peering.  These six messages<em> </em>   typically occur between an OSP client such as a VoIP gateway, SIP Proxy or softswitch and an OSP    Server.  These messages, written    in   <em>italics,</em> are:</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;">   <font face="Arial" size="2">1.</font><span style="font-style:normal;font-variant:normal;font-weight:normal;font-family:Arial;"><font size="2">   </font></span><font face="Arial" size="2"><em>AuthorizationRequest</em><!--[if supportFields]&amp;gt;:   -->The message sent from an OSP client (i.e. source gateway) to the    OSP  Server requesting one or more routes and authorization to a    destination gateway that can complete the call to the dialed number.</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;">   <font face="Arial" size="2">2.</font><span style="font-style:normal;font-variant:normal;font-weight:normal;font-family:Arial;"><font size="2">   </font></span><font face="Arial" size="2"><em>AuthorizationResponse:</em><!--[if supportFields]&amp;gt;   -->The response from the OSP  Server to the <em>   AuthorizationRequest</em> from a source gateway.  This message includes    one or more IP addresses of destination devices that can complete the VoIP    call to the dialed number.  Each destination IP address is accompanied    with an authorization token digitally signed by the OSP Server.  The    authorization token is included in the call set-up request from the source    device to the destination device.  The destination device validates the token    before accepting the call set-up request from the source device.</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;">   <font face="Arial" size="2">3.</font><span style="font-style:normal;font-variant:normal;font-weight:normal;font-family:Arial;"><font size="2">   </font></span><font face="Arial" size="2"><em>UsageIndication</em>:    This message is the OSP defined message for reporting usage.  The source and    destination devices automatically send a <em>UsageIndication</em> message to the    OSP  Server when the call is completed.</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;">   <font face="Arial" size="2">4.</font><span style="font-style:normal;font-variant:normal;font-weight:normal;font-family:Arial;"><font size="2">   </font></span><font face="Arial" size="2"><em>UsageConfirmation</em></font><!--[if supportFields]&amp;gt;--><font face="Arial" size="2">:    The OSP Server responds to each <em>UsageIndication</em> message with a <em>   UsageConfirmation</em> message.  A source or destination device will continue    to send a <em>UsageIndication</em> message for a call until it receives a <em>   UsageConfirmation</em> from the OSP Server.</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-bottom:0;">   <font face="Arial" size="2">5.   <em>CapabilitiesIndication</em>:    This versatile message is sent from an OSP client to an OSP Server.  The    OSP client may use the capabilities exchange message to transmit the following    information to an OSP Server:</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">              a.  Serial number and customerID (can be used for self provisioning)</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">              b.  Services requested from the OSP Server (i.e. routing, accounting or    both) </font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-top:0;margin-bottom:0;">   <font face="Arial" size="2">              c.  OSP version supported</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-top:0;">   <font face="Arial" size="2">              d.  Available bandwidth and channel resources (a client can indicate to    an OSP Server that it should be added or removed from routing based on its    available resources.)</font></p>
<p class="MsoBodyText" style="text-indent:-0.25in;margin-left:0.5in;margin-top:0;">   <font face="Arial" size="2">6.   <em>CapabilitiesConfirmation</em>:    The OSP Server responds to each <em>CapabilitiesIndication</em> message with a   <em>CapabilitiesConfirmation</em> message.</font></p>
<h2><strong>   <font color="#000080" face="Arial" size="2">Simple OSP Call Scenario</font></strong></h2>
<p class="MsoBodyText" style="margin-top:0;margin-bottom:6pt;">   <font face="Arial" size="2">A single OSP Server authorizes a peer to peer call    between two voice over IP gateways.  The originating (source) peer makes an OSP <em>   AuthorizationRequest</em> to the OSP Server for the IP address of a terminating    (destination) peer that can complete the call to the dialed number.  The OSP <em>AuthorizationResponse</em>    includes the IP address of the terminating (destination) peer and a peering authorization token digitally signed by the OSP        Server.   </font></p>
<p>      <font face="Arial" size="2">The originating (source) peer includes the peering authorization    token</font><!--[if supportFields]&amp;gt;--><font face="Arial" size="2"> in the call set-up to the terminating    (destination) peer. An peering authorization token can be included in a Q.931    call set-up message or in a SIP INVITE message.  The terminating gateway recognizes the     authorization token in the call set-up, validates that the authorization token    was digitally signed by a trusted peering authority.</font></p>
<p><img src="http://www.transnexus.com/Products/What%20i1.gif" height="256" width="448" /><br />
<img src="http://www.transnexus.com/Products/What%20i2.gif" height="227" width="448" /></p>
<p class="MsoBodyText" style="margin-bottom:0.0001pt;">   <font face="Arial" size="2">As shown in the illustration below, when the call ends, the    originating and terminating gateways send their <em>UsageIndication</em>    messages to the OSP Server.  The OSP Server responds by sending a <em>   UsageConfirmation</em> message (not shown) to the originating and terminating    gateways.</font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=25&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/10/10/what-is-osp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>

		<media:content url="http://www.transnexus.com/Products/What%20i1.gif" medium="image" />

		<media:content url="http://www.transnexus.com/Products/What%20i2.gif" medium="image" />
	</item>
		<item>
		<title>Oracle Open Source : TOra (Toolkit for Oracle)</title>
		<link>http://gudangberas.wordpress.com/2006/08/11/oracle-open-source-tora-toolkit-for-oracle/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/11/oracle-open-source-tora-toolkit-for-oracle/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 02:56:22 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/11/oracle-open-source-tora-toolkit-for-oracle/</guid>
		<description><![CDATA[Inspired by this article by Lucas Jellema I ventured to see what the “Open Source community�? has to offer to an average Oracle-developer like myself. The first stop was http://www.oracle.com/technology/tech/opensource/projects.html for a brief introduction to some of the open source projects related to Oracle. The first thing that caught my eye was TOra, a Toolkit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=24&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://www.amis-de.com/files/AD_ODTUG2004crossbreeding_Java2PLSQL.doc">this</a> article by Lucas Jellema I ventured to see what the “Open Source community�? has to offer to an average Oracle-developer like myself.  The first stop was <a href="http://www.oracle.com/technology/tech/opensource/projects.html">http://www.oracle.com/technology/tech/opensource/projects.html</a> for a brief introduction to some of the open source projects related to Oracle.   The first thing that caught my eye was <a href="http://www.globecom.net/tora/">TOra, a Toolkit for Oracle</a> hence the name. If you’ve used Toad in the past, this tool will be very familiar to you.  TOra s born out of <a href="http://www.globecom.net/tora/history.html">jealousy</a>. Windows users have an abundance of tools to choose from, Linux user however, don’t… or at least didn’t. TOra filled this gap. It was created in C++ and uses the Qt library. In the included documentation, there is a section explaining ways to create plug-ins for TOra. It even includes a tutorial. The only <a href="http://log4plsql.sourceforge.net/download/log4plsql.tpl">plug-in</a> I could find incorporates <a href="http://log4plsql.sourceforge.net/">Log4PLSQL</a> into TOra. While using Google to search for plug-ins available for TOra I came across a post mentioning a plug-in for SQL*Loader, I couldn’t find the actual plug-in though. TOra is free of charge, unless you’re a Windows user, then you’ll need to purchase a commercial license. The Windows version of TOrais governed by <a href="http://www.globecom.se/tora/license.pdf">the Software License Agreement from Quest Software.</a> Other platform releases are licensed under <a href="http://www.gnu.org/copyleft/gpl.html">GPL</a>.  Features included in TOra:</p>
<ul>
<li>PL/SQL Debugger, at least according to the specs. I couldn’t get it going. The      menu showed the icon, but was disabled.</li>
<li>SQL Worksheet with syntax highlighting. Tab Pages provide additional      information such as Explain Plan and a Log of previously executed      statements<br />
A nice feature here is the “describe under cursor�? which shows the table      structure you a currently querying.</li>
<li>Schema Browser to show tables, view, indexes , sequences, synonyms, pl/sql and triggers for a particular schema.</li>
</ul>
<p>Here is a screenshot showcasing some of these features.  <img src="http://technology.amis.nl/blog/wp-content/images/ToraScreenshot.png" alt="TOra Screenshot" /> TOra supports Database versions up to Oracle 9i (which release is not specified). Being connected to an Oracle 10g database didn’t seem to cause any problems. I installed a trial version on a Windows platform and played around with that for a while. The first thing that strikes me is the resemblance to Toad. There are a lot of similarities between these two products. The overall look and feel, where the different tools are located etc. make clear that TOra was inspired by Toad. My experience with TOra… it has a lot of features I never use. The ones I do use, don’t provide me with the feedback I need. An example to illustrate this: If I create a procedure with an error in it. It will compile, or at least it appears that way. The error messages are shown on the status bar and disappear after a while. You can recall the messages using a button on the status bar, or navigate the cursor to the status bar to display the error message in a tooltip. What I’d like to see is more immediate feedback to notice errors early on during development. Toad will display a pop-up window clearly stating the error. Creating and manipulating Objects formed somewhat of a problem in the SQL Worksheet. A valid Object Type Body definition (tested in SQL*Plus) resulted in an “ORA-00900: Invalid SQL Statement” error, making it impossible to create the Object Type Body here. Doing a similar action(creating a Object Type Body in a SQL window) in Toad or SQL*Plus was no problem. A valid Object Type Body was the result. A really nice feature in TOra is the DB Extract/Compare/Search tool. Simply using check-marks to specify which database objects you want to use and this tool will either Extract (creating installation scripts), Compare (handy if you need to compare two schema’s) or Search the database. I think it’s possible to overcome the limitations I mentioned before, once you get more comfortable using this tool. Getting used to a tool like Toad or TOra requires some time. There are so many tools at your disposal, learning each one of them simply takes time and effort. It’s like a new pair of shoes, once you break them in, they’re comfortable to wear, but the first two weeks… There are a number of tools on the market to choose from, especially if you’re using Windows. TOra beats Toad price-wise, but for how long? Quest is involved in TOra, draw your own conclusion. How will it compete with others on the Windows platform? Is it still going to evolve and incorporate new features and enhancements? If you’re not on a Windows platform, TOramight be worth looking into. The price is right, it offers a lot (maybe most) of the features Toad has. Jealousy can be a thing of the past.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=24&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/11/oracle-open-source-tora-toolkit-for-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>

		<media:content url="http://technology.amis.nl/blog/wp-content/images/ToraScreenshot.png" medium="image">
			<media:title type="html">TOra Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Online Reports with Oracle and PHP</title>
		<link>http://gudangberas.wordpress.com/2006/08/11/creating-online-reports-with-oracle-and-php/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/11/creating-online-reports-with-oracle-and-php/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 02:53:26 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/11/creating-online-reports-with-oracle-and-php/</guid>
		<description><![CDATA[The ability to generate database-driven reports is a &#8220;must-have&#8221; in most Web-based applications. In order to create a complex report, most developers resort to employing composite data sets&#8211;those sets that cannot be retrieved by running just a single SQL query but rather by executing a collection of smaller queries in a loop. Although this approach [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=23&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The ability to generate database-driven reports is a &#8220;must-have&#8221; in most Web-based applications. In order to create a complex report, most developers resort to employing composite data sets&#8211;those sets that cannot be retrieved by running just a single SQL query but rather by executing a collection of smaller queries in a loop.</p>
<p>Although this approach is often appropriate, there are alternatives. In this recipe, you will learn alternative techniques that rely on variable binding and Oracle&#8217;s CURSOR expressions and measure these against the traditional approach. All the code is included, so you should be able to replicate the testing conditions and do some benchmarking of your own.</p>
<h2>Setting Up the Data Structure</h2>
<p>For this recipe I am going to reuse the example from the <a href="http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/seliverstov_multirows.html" class="bodylink">&#8220;Inserting Multiple Rows With One Database Call Using PHP and Oracle Collections&#8221;</a> recipe that illustrated how to use Oracle cursors to speed up bulk data inserts. In that recipe, you created a simple database structure that could be used to support a hypothetical e-commerce Web application. Here you will add another table that can be used to track status changes to each order (Order received -&gt; Order processed -&gt; Order packed -&gt; Order shipped). In other words, by looking at this table, you will be able to tell the current status, as well as the history of status changes, for any given order.</p>
<p>Here is the rehashed data structure:</p>
<p><img src="http://www.oracle.com/technology/pub/images/mikhail-reports-f1.gif" alt="figure 1" />Here is the SQL code to create the tables above:</p>
<pre><font size="-1">
CREATE TABLE CUSTOMERS (
  CUSTOMER_ID    NUMBER        NOT NULL,
  CUSTOMER_NAME  VARCHAR2 (100)  NOT NULL,
  CONSTRAINT PK_CUSTOMERS
  PRIMARY KEY ( CUSTOMER_ID ) ) ;
/
CREATE TABLE ITEMS (
  ITEM_ID           NUMBER        NOT NULL,
  ITEM_DESCRIPTION  VARCHAR2 (50)  NOT NULL,
  ITEM_PRICE        NUMBER        NOT NULL,
  CONSTRAINT PK_ITEMS
  PRIMARY KEY ( ITEM_ID ) ) ;
/
CREATE TABLE ORDERS (
  ORDER_ID     NUMBER        NOT NULL,
  ORDER_DATE   DATE          NOT NULL,
  CUSTOMER_ID  NUMBER,
  CONSTRAINT PK_ORDERS
  PRIMARY KEY ( ORDER_ID ) ) ; 

ALTER TABLE ORDERS ADD  CONSTRAINT FK_CUSTOMER
 FOREIGN KEY (CUSTOMER_ID)
  REFERENCES CUSTOMERS (CUSTOMER_ID) ;
/
CREATE TABLE ORDER_ITEMS (
  ORDER_LINE_ID  NUMBER        NOT NULL,
  ORDER_ID       NUMBER        NOT NULL,
  ITEM_ID        NUMBER        NOT NULL,
  CONSTRAINT PK_ORDER_ITEMS
  PRIMARY KEY ( ORDER_LINE_ID ) ) ; 

ALTER TABLE ORDER_ITEMS ADD  CONSTRAINT FK_ITEM
 FOREIGN KEY (ITEM_ID)
  REFERENCES ITEMS (ITEM_ID) ;

ALTER TABLE ORDER_ITEMS ADD  CONSTRAINT FK_ORDER
 FOREIGN KEY (ORDER_ID)
  REFERENCES ORDERS (ORDER_ID) ;

/
CREATE TABLE ORDER_TRACKING (
  RECORD_ID       NUMBER        NOT NULL,
  CURRENT_STATUS  VARCHAR2 (100),
  ORDER_ID        NUMBER,
  RECORD_DATE     DATE,
  CONSTRAINT PK_ORDER_TRACKING
  PRIMARY KEY ( RECORD_ID ) ) ; 

ALTER TABLE ORDER_TRACKING ADD  CONSTRAINT FK_ORDER_TRACKING
 FOREIGN KEY (ORDER_ID)
  REFERENCES ORDERS (ORDER_ID) ;

CREATE SEQUENCE ORDER_LINE_SQ
INCREMENT BY 1;
/

CREATE SEQUENCE ORDER_STATUS_SQ
INCREMENT BY 1;
/
</font></pre>
<p>And a sequence to make it simple to come up with a unique primary key whenever a row is inserted in the Order_Items table:</p>
<pre><font size="-1">
CREATE SEQUENCE ORDER_LINE_SQ
INCREMENT BY 1;
/
</font></pre>
<p>And here&#8217;s the code to populate the test data. Assume that the CUSTOMERS table is pre-populated with the customer CUSTOMER_ID = 1 and the ITEMS table contains 15 items with ITEM_IDs from 1 to 15:</p>
<pre><font size="-1">
//connect to the database using your login name and password
$schema = "my_schema";
$ password = "my_password";

$db = oci_connect('$schema, $password) or die;

$arr_order_items = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); //all items on the list
$arr_status = array("Received","Processed","Packed","Shipped");

//create 200 orders for CUSTOMER_ID = 1

for ($order_id = 1;$order_id&lt;=200;$order_id++) {
   $sql = "INSERT INTO ORDERS (order_id,customer_id,order_date) VALUES (".$order_id.",1,SYSDATE)";
   $stmt = oci_parse($db,$sql);
   oci_execute($stmt);
//add 15 items to each order
   foreach ($arr_order_items as $item) {
      $sql = "INSERT INTO ORDER_ITEMS (order_line_id,order_id,item_id) VALUES
      (ORDER_LINE_SQ.nextval,".$order_id.",".$item.")";
      $stmt = oci_parse($db,$sql);
      oci_execute($stmt);
   }
//populate status for each order
   foreach ($arr_status as $status) {
      $sql = "INSERT INTO ORDER_TRACKING (order_id,current_status,record_date) VALUES
      (".$order_id.",'".$status."',SYSDATE)";
      $stmt = oci_parse($db,$sql);
      oci_execute($stmt);
  }
}
</font></pre>
<p>At this point the ORDERS table should be populated with 200 orders placed by customer 1. Each order comes with 15 items in the ORDER_ITEMS table and 4 statuses in the ORDER_TRACKING table.</p>
<h2>Report Requirements</h2>
<p>First, create an order history report for your only customer (CUSTOMER_ID = 1). The report will present the complete list of customer&#8217;s orders with two subsections: one that shows the items included with each given order, and one that lists this order&#8217;s status update history. In the following sections, you will create this report using three different techniques: by executing a series of stand-alone database calls in loop, by executing the same stand-alone queries with variable binding, and by using Oracle&#8217;s CURSOR expressions in a single query.</p>
<p><strong>Simple sub-queries.</strong> This approach is, no doubt, the most traditional way of building complex reports. In this example you will execute a simple query to retrieve the list orders for given customer id and then loop through the list of orders and execute two sub-queries, one to get the status change history and the other to get the item list. The results will be stored in an associative array $arr_orders and later presented as an HTML table.</p>
<pre><font size="-1">
$stmt = oci_parse($db,"SELECT order_id,order_date,customer_name FROM CUSTOMERS,ORDERS WHERE
ORDERS.customer_id = 1 AND ORDERS.CUSTOMER_ID = CUSTOMERS.CUSTOMER_ID");

oci_execute($stmt);

while (oci_fetch_assoc($stmt,$orders)) {
   $arr_order_status = array(); // to temporarily store status history for given order id
   $arr_order_items = array(); // to temporarily store item list for given order id
   $arr_order_line = array(); // to temporarily store complete order information for given order id

$arr_order_line =    array("ORDER_ID"=&gt;$orders["ORDER_ID"],"ORDER_DATE"=&gt;$orders["ORDER_DATE"],
   "CUSTOMER_NAME"=&gt;$orders["CUSTOMER_NAME"]);

//first "sub-query"
   $stmt2 = oci_parse($db,"SELECT current_status,record_date FROM ORDER_TRACKING WHERE order_id = ".$orders["ORDER_ID"]);

oci_execute($stmt2);

while (oci_fetch_assoc($stmt2,$status)) { //note that this function is PHP5 only, use OCIFetchInto for PHP4
      $arr_order_status[] = array("CURRENT_STATUS"=&gt;$status["CURRENT_STATUS"],
      "RECORD_DATE"=&gt;$status[ "RECORD_DATE" ]);
   }

$arr_order_line["STATUS"] = $arr_order_status;

//second "sub-query"
   $stmt3 = Oci_parse($db,"SELECT item_description,item_price FROM ITEMS,ORDER_ITEMS WHERE
   ORDER_ITEMS.ITEM_ID = ITEMS.ITEM_ID AND ORDER_ITEMS.ORDER_ID = ".$orders["ORDER_ID"]);
   oci_execute($stmt3);
   while (oci_fetch_assoc($stmt3,$items)) {
      $arr_order_items[] = array("ITEM_DESCRIPTION"=&gt;$items["ITEM_DESCRIPTION"],
      "ITEM_PRICE"=&gt;$items["ITEM_PRICE"]);
   }

$arr_order_line["ITEMS"] = $arr_order_items;

//add new line to the orders array
   $arr_orders[] = $arr_order_line;
}
</font></pre>
<p><strong>Simple sub-queries with variable binding.</strong> This approach is similar to the previous technique; it also relies on executing stand-alone database queries in a loop. However, this time you will use variable binding.  In theory, using variable binding should result in faster query execution, since Oracle wouldn&#8217;t have to parse each and every new statement. Also, binding is generally safer, since it reduces the risk of a SQL injection attack.</p>
<pre><font size="-1">
$stmt = oci_parse($db,"SELECT order_id,order_date,customer_name FROM CUSTOMERS,
                  ORDERS WHERE ORDERS.customer_id = 1 AND ORDERS.CUSTOMER_ID = CUSTOMERS.CUSTOMER_ID");

//parse the statement to get status update history and bind it to the variable
$stmt2 = oci_parse($db,"SELECT current_status,record_date FROM ORDER_TRACKING WHERE order_id = :var");
oci_bind_by_name($stmt2, ":var", $order_id,32);

//parse the statement to get item list and bind it to the variable
$stmt3 = oci_parse($db,"SELECT item_description,item_price FROM ITEMS,
                   ORDER_ITEMS WHERE ORDER_ITEMS.ITEM_ID = ITEMS.ITEM_ID AND ORDER_ITEMS.ORDER_ID = :var");
oci_bind_by_name ($stmt3, ":var", $order_id,32);

oci_execute($stmt); //execute order list statement

while (OCIFetchInto($stmt,$orders)) {
   $arr_order_status = array();
   $arr_order_items = array();
   $arr_order_line = array();

$arr_order_line = array("ORDER_ID"=&gt;$orders["ORDER_ID"],"ORDER_DATE"=&gt;$orders["ORDER_DATE"],
   "CUSTOMER_NAME"=&gt;$orders["CUSTOMER_NAME"]);

$order_id = $orders["ORDER_ID"]; //current order id

//first "sub-query"
   oci_execute($stmt2);
   while (oci_fetch_assoc($stmt2,$status)) {
      $arr_order_status[] = array("CURRENT_STATUS"=&gt;$status["CURRENT_STATUS"],
      "RECORD_DATE"=&gt;$status[ "RECORD_DATE" ]);
   }

$arr_order_line["STATUS"] = $arr_order_status;

//second "sub-query"
   oci_execute($stmt3);
   while (oci_fetch_assoc($stmt3,$items)) {
      $arr_order_items[] = array("ITEM_DESCRIPTION"=&gt;$items["ITEM_DESCRIPTION"],
      "ITEM_PRICE"=&gt;$items["ITEM_PRICE"]);
   }

$arr_order_line["ITEMS"] = $arr_order_items;

//add new line to the orders array
   $arr_orders[] = $arr_order_line;
}
</font></pre>
<p><strong>Single query with Oracle CURSOR sub-queries.</strong> The third approach involves using Oracle&#8217;s CURSOR expressions in a single database call. Even though there is still quite a bit of looping involved, this time, instead of querying the original database tables you will query the collections included in the initial call.</p>
<pre><font size="-1">
$stmt = oci_parse($db,"SELECT order_id,order_date,customer_name,
CURSOR(SELECT current_status,record_date FROM ORDER_TRACKING WHERE order_id = ORDERS.order_id) as status,
CURSOR(SELECT item_description,item_price FROM ITEMS,
       ORDER_ITEMS WHERE ORDER_ITEMS.ITEM_ID = ITEMS.ITEM_ID AND ORDER_ITEMS.ORDER_ID = ORDERS.order_id) AS items
FROM CUSTOMERS, ORDERS WHERE ORDERS.customer_id = 1
AND ORDERS.CUSTOMER_ID = CUSTOMERS.CUSTOMER_ID");

oci_execute($stmt);
while (oci_fetch_assoc ($stmt,$orders)) {
   $arr_order_status = array();
   $arr_order_items = array();
   $arr_order_line = array();

$arr_order_line = array("ORDER_ID"=&gt;$orders["ORDER_ID"],"ORDER_DATE"=&gt;$orders["ORDER_DATE"],
   "CUSTOMER_NAME"=&gt;$orders["CUSTOMER_NAME"]);

//process cursors
   oci_execute($orders["STATUS"]); //get data from the nested collection
   while (oci_fetch_assoc($orders["STATUS"],$status)) {
      $arr_order_status[] = array("CURRENT_STATUS"=&gt;$status["CURRENT_STATUS"],
      "RECORD_DATE"=&gt;$status["RECORD_DATE"]);
   }

$arr_order_line["STATUS"] = $arr_order_status;

oci_execute($orders["ITEMS"]);
   while (OCIFetchinto($orders[ "ITEMS" ],$items,OCI_ASSOC)) {
      $arr_order_items[] = array("ITEM_DESCRIPTION"=&gt;$items["ITEM_DESCRIPTION"],
      "ITEM_PRICE"=&gt;$items["ITEM_PRICE"]);
   }

$arr_order_line["ITEMS"] = $arr_order_items;

//add new line to the orders array
   $arr_orders[] = $arr_order_line;
}
</font></pre>
<h2>Viewing the Report</h2>
<p>The report data is now contained in the $arr_orders array. Here is a little snippet of code that loops through the array and renders the data as an HTML table for easy viewing. Since in our example all orders are identical, this snippet will only show the first two orders.</p>
<pre><font size="-1">
for($i=0;$i&lt;=1;$i++) { //show only the first two orders
   echo "&lt;table cellpadding=\"2\" cellspacing=\"2\" width=\"500\" border=\"1\"&gt;";
   echo "&lt;tr&gt;&lt;td colspan=\"2\"&gt;Order # ".($i+1)." (".$arr_orders[$i]["ORDER_ID"]." "
   .$arr_orders[$i]["ORDER_DATE"].",".$arr_orders[$i]["CUSTOMER_NAME"].")&lt;/td&gt;&lt;/tr&gt;";
   echo "&lt;tr&gt;&lt;td valign=\"top\"&gt;";
   foreach($arr_orders[$i]["STATUS"] as $status) {
      echo $status["RECORD_DATE"]." - ".$status["CURRENT_STATUS"]."&lt;br /&gt;";
   }
   echo "&lt;/td&gt;&lt;td valign=\"top\"&gt;";
   foreach($arr_orders[$i]["ITEMS"] as $item) {
      echo $item["ITEM_DESCRIPTION"]." - ".$item["ITEM_PRICE"]."&lt;br /&gt;";
   }
   echo "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
}
</font></pre>
<h2>Benchmarking</h2>
<p>Finally, review the results and decide which method would be the most efficient way to produce reports for your system. Keep in mind, however, that no two systems are identical and there are many factors to consider while optimizing for best performance. Some factors may be database related (like fine-tuning the indexes), some may involve the PHP or network optimization, and so on. As to the simple system discussed here, feel free to draw your own conclusions by looking at the tables below:</p>
<h3>200 orders</h3>
<table border="1" cellpadding="3" cellspacing="0" width="593">
<tr valign="top">
<td width="106"><strong>Attempt #</strong></td>
<td width="155"><strong>Method 1, sec.</strong></td>
<td width="131"><strong>Method 2, sec.</strong></td>
<td width="135"><strong>Method 3, sec.</strong></td>
</tr>
</table>
<h3>1,000 orders</h3>
<table border="1" cellpadding="3" cellspacing="0" width="593">
<tr valign="top">
<td width="104"><strong>Attempt #</strong></td>
<td width="157"><strong>Method 1, sec.</strong></td>
<td width="131"><strong>Method 2, sec.</strong></td>
<td width="135"><strong>Method 3, sec.</strong></td>
</tr>
</table>
<h2>Conclusion</h2>
<p>There are, of course, more ways to provide same functionality&#8211;for example, by using an Oracle stored procedure with REF CURSORs to output the data. As you can see, in this particular test, it turned out that using stand-alone sub-queries would provide better performance. However, this test is by no means comprehensive and I encourage you to use the code presented in this recipe to create your own tests and find out which method works best for you.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=23&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/11/creating-online-reports-with-oracle-and-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>

		<media:content url="http://www.oracle.com/technology/pub/images/mikhail-reports-f1.gif" medium="image">
			<media:title type="html">figure 1</media:title>
		</media:content>
	</item>
		<item>
		<title>Using ADOdb with PHP and Oracle: an advanced tutorial</title>
		<link>http://gudangberas.wordpress.com/2006/08/11/using-adodb-with-php-and-oracle-an-advanced-tutorial/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/11/using-adodb-with-php-and-oracle-an-advanced-tutorial/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 02:48:05 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/11/using-adodb-with-php-and-oracle-an-advanced-tutorial/</guid>
		<description><![CDATA[1. Introduction Oracle is the most popular commercial database used with PHP. There are many ways of accessing Oracle databases in PHP. These include: The oracle extension The oci8 extension PEAR DB library ADOdb library The wide range of choices is confusing to someone just starting with Oracle and PHP. I will briefly summarize the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=22&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>1. Introduction</h3>
<p>Oracle is the most popular commercial database used with PHP. There are many ways of accessing Oracle databases in PHP. These include:</p>
<ul>
<li>The oracle extension</li>
<li>The oci8 extension</li>
<li>PEAR DB library</li>
<li>ADOdb library</li>
</ul>
<p>The wide range of choices is confusing to someone just starting with Oracle and PHP. I will briefly summarize the differences, and show you the advantages of using <a href="http://adodb.sourceforge.net/">ADOdb</a>.</p>
<p>First we have the C extensions which provide low-level access to Oracle functionality. These C extensions are precompiled into PHP, or linked in dynamically when the web server starts up. Just in case you need it, here&#8217;s a <a href="http://www.oracle.com/technology/tech/opensource/php/apache/inst_php_apache_linux.html">guide to installing Oracle and PHP on Linux</a>.</p>
<table align="center" border="1" width="75%">
<tr valign="top">
<td nowrap="nowrap"><b>Oracle extension</b></td>
<td>Designed for Oracle 7 or earlier. This is obsolete.</td>
</tr>
</table>
<p>Here is an example of using the oci8 extension to query the <i>emp</i> table of the <i>scott</i> schema with bind parameters:</p>
<pre>$conn = OCILogon("scott","tiger", $tnsName); 

$stmt = OCIParse($conn,"select * from emp where empno &gt; :emp order by empno");
$emp = 7900;
OCIBindByName($stmt, ':emp', $emp);
$ok = OCIExecute($stmt);
while (OCIFetchInto($stmt,$arr)) {
	print_r($arr);
	echo "&lt;hr&gt;";
}</pre>
<p>This generates the following output:</p>
<p class="greybg">Array ( [0] =&gt; 7902 [1] =&gt; FORD [2] =&gt; ANALYST [3] =&gt; 7566 [4] =&gt; 03/DEC/81 [5] =&gt; 3000 [7] =&gt; 20 )<br />
<hr />   Array ( [0] =&gt; 7934 [1] =&gt; MILLER [2] =&gt; CLERK [3] =&gt; 7782 [4] =&gt; 23/JAN/82 [5] =&gt; 1300 [7] =&gt; 10 )</p>
<p>We also have  many higher level PHP libraries that allow you to simplify the above code. The most popular are <a href="http://pear.php.net/">PEAR DB</a> and <a href="http://adodb.sourceforge.net/">ADOdb</a>.  Here are some of the differences between these libraries:</p>
<table align="center" border="1" width="75%">
<tr>
<td><b>Feature</b></td>
<td><b>PEAR DB 1.6</b></td>
<td><b>ADOdb 4.52</b></td>
</tr>
</table>
<p>PEAR DB is good enough for simple web apps. But if you need more power, you can see ADOdb offers more sophisticated functionality. The rest of this article will concentrate on using ADOdb with Oracle. You can find out more about <a href="http://phplens.com/lens/adodb/docs-oracle.htm#connecting">connecting to Oracle</a> later in this guide.</p>
<h4>ADOdb Example</h4>
<p>In ADOdb, the above oci8 example querying the <i>emp</i> table could be written as:</p>
<pre>include "/path/to/adodb.inc.php";
$db = NewADOConnection("oci8");
$db-&gt;Connect($tnsName, "scott", "tiger");

$rs = $db-&gt;Execute("select * from emp where empno&gt;:emp order by empno",
                    array('emp' =&gt; 7900));
while ($arr = $rs-&gt;FetchRow()) {
    print_r($arr);
	echo "&lt;hr&gt;";
}</pre>
<p>The Execute( ) function returns a recordset object, and you can retrieve the rows returned using $recordset-&gt;FetchRow( ).</p>
<p>If we ignore the initial connection preamble, we can see the ADOdb version is much easier and simpler:</p>
<table border="1" width="100%">
<tr bgcolor="#ffffff" valign="top">
<td bgcolor="#e0e0e0" width="50%"><b>Oci8</b></td>
<td bgcolor="#e0e0e0"><b>ADOdb</b></td>
</tr>
<tr bgcolor="#cccccc" valign="top">
<td>
<pre><font size="1">$stmt = <b>OCIParse</b>($conn,
       "select * from emp where empno &gt; :emp");
$emp = 7900;
<b>OCIBindByName</b>($stmt, ':emp', $emp);
$ok = <b>OCIExecute</b>($stmt);

while (<b>OCIFetchInto</b>($stmt,$arr)) {
	print_r($arr);
	echo "&lt;hr&gt;";
} </font></pre>
</td>
<td>
<pre><font size="1">$recordset = $db-&gt;<b>Execute</b>("select * from emp where empno&gt;:emp",
                           array('emp' =&gt; 7900));

while ($arr = $recordset-&gt;<b>FetchRow</b>()) {
	print_r($arr);
	echo "&lt;hr&gt;";
}</font></pre>
</td>
</tr>
</table>
<h3>2. ADOdb Query Semantics</h3>
<p>You can also query the database using the standard Microsoft ADO MoveNext( ) metaphor. The data array for the current row is stored in the <i>fields</i> property of the recordset object, $rs. MoveNext( ) offers the highest performance among all the techniques for iterating through a recordset:</p>
<pre>$rs = $db-&gt;Execute("select * from emp where empno&gt;:emp", array('emp' =&gt; 7900));
while (!$rs-&gt;EOF) {
	print_r($rs-&gt;fields);
	$rs-&gt;MoveNext();
}</pre>
<p>And if you are interested in having the data returned in a 2-dimensional array, you can use:</p>
<pre>$arr = $db-&gt;GetArray("select * from emp where empno&gt;:emp", array('emp' =&gt; 7900));</pre>
<p>Now to obtain only the first row as an array:</p>
<pre>$arr = $db-&gt;GetRow("select * from emp where empno=:emp", array('emp' =&gt; 7900));</pre>
<p>Or to retrieve only the first field of the first row:</p>
<pre>$arr = $db-&gt;GetOne("select ename from emp where empno=:emp", array('emp' =&gt; 7900));</pre>
<p>For easy pagination support, we provide the SelectLimit function. The following will perform a select query, limiting it to 100 rows, starting from row 201 (row 1 being the 1st row):</p>
<pre>$offset = 200; $limitrows = 100;
$rs = $db-&gt;SelectLimit('select * from table', $limitrows, $offset);</pre>
<p>The $offset parameter is optional.</p>
<h4>Array Fetch Mode</h4>
<p>When data is being returned in an array, you can choose the type of array the data is returned in.</p>
<ol>
<li>Numeric indexes &#8211; use <font face="Courier New, Courier, mono" size="2">$connection-&gt;SetFetchMode(ADODB_FETCH_NUM).</font></li>
<li>Associative indexes &#8211; the keys of the array are the names of the fields (in upper-case). Use <font face="Courier New, Courier, mono" size="2">$connection-&gt;SetFetchMode(ADODB_FETCH_ASSOC)</font><font face="Courier New, Courier, mono">.</font></li>
<li>Both numeric and associative indexes &#8211; use <font face="Courier New, Courier, mono" size="2">$connection-&gt;SetFetchMode(ADODB_FETCH_BOTH).</font></li>
</ol>
<p>The default is ADODB_FETCH_BOTH for Oracle.</p>
<h4><b>Caching</b></h4>
<p>You can define a database cache directory using $ADODB_CACHE_DIR, and cache the results of frequently used queries that rarely change. This is particularly useful for SQL with complex where clauses and group-by&#8217;s and order-by&#8217;s. It is also good for relieving heavily-loaded database servers.</p>
<p>This example will cache the following select statement for 3600 seconds (1 hour):</p>
<pre>$ADODB_CACHE_DIR = '/var/adodb/tmp';
$rs = $db-&gt;CacheExecute(3600, "select names from allcountries order by 1");</pre>
<p>There are analogous CacheGetArray( ), CacheGetRow( ), CacheGetOne( ) and CacheSelectLimit( ) functions. The first parameter is the number of seconds to cache. You can also pass a bind array as a 3rd parameter (not shown above).There is an alternative syntax for the caching functions. The first parameter is omitted, and you set the cacheSecs  property of the connection object:</p>
<pre>$ADODB_CACHE_DIR = '/var/adodb/tmp';
$connection-&gt;cacheSecs = 3600;
$rs = $connection-&gt;CacheExecute($sql, array('id' =&gt; 1));</pre>
<h3></h3>
<h3>3. Using Prepare( ) For Frequently Used Statements</h3>
<p>Prepare( ) is for compiling frequently used SQL statement for reuse. For example, suppose we have a large array which needs to be inserted into an Oracle database. The following will result in a massive speedup in query execution (at least 20-40%), as the SQL statement only needs to be compiled once:</p>
<pre>$stmt = $db-&gt;Prepare('insert into table (field1, field2) values (:f1, :f2)');
foreach ($arrayToInsert as $key =&gt; $value) {
	$db-&gt;Execute($stmt, array('f1' =&gt; $key, 'f2' =&gt; $val);
}</pre>
<h3>4. Working With LOBs</h3>
<p>Oracle treats data which is more than 4000 bytes in length specially. These are called Large Objects, or LOBs for short. Binary LOBs are BLOBs, and character LOBs are CLOBs. In most Oracle libraries, you need to do a lot of work to process LOBs, probably because Oracle designed it to work in systems with little memory. ADOdb tries to make things easy by assuming the LOB can fit into main memory.</p>
<p>ADOdb will transparently handle LOBs  in <i>select</i> statements. The LOBs are automatically converted to PHP variables without any special coding.</p>
<p>For updating records with LOBs, the functions UpdateBlob( ) and UpdateClob( ) are provided. Here&#8217;s a BLOB example. The parameters should be self-explanatory:</p>
<pre>$ok = $db-&gt;Execute("insert into aTable (id, name, ablob)
                                values (aSequence.nextVal, 'Name', null)");
if (!$ok) return LogError($db-&gt;ErrorMsg());
<font color="#006600"># params: $tableName, $blobFieldName, $blobValue, $whereClause</font>
$db-&gt;UpdateBlob('aTable', 'ablob', $blobValue, 'id=aSequence.currVal');</pre>
<p>and the analogous CLOB example:</p>
<pre>$ok = $db-&gt;Execute("insert into aTable (id, name, aclob)
                                values (aSequence.nextVal, 'Name', null)");
if (!$ok) return LogError($db-&gt;ErrorMsg());
$db-&gt;UpdateClob('aTable', 'aclob', $clobValue, 'id=aSequence.currVal');</pre>
<p>Note that LogError( ) is a user-defined function, and not part of ADOdb.</p>
<p>Inserting LOBs is more complicated. Since ADOdb 4.55, we allow you to do this   (assuming that the <em>photo</em> field is a BLOB, and we want to store $blob_data into   this field, and the primary key is the <em>id</em> field):</p>
<pre>$sql = <span class="style1">"INSERT INTO photos ( ID, photo) ".
			"VALUES ( :id, empty_blob() )".
			" RETURNING photo INTO <img src='http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> x"</span>;

$stmt = $db-&gt;PrepareSP($sql);
		$db-&gt;InParameter($stmt, $<strong>id</strong>, <span class="style1">'id'</span>);
		$blob = $db-&gt;InParameter($stmt, $<strong>blob_data</strong>, <span class="style1">'xx'</span>,-1, OCI_B_BLOB);
		$db-&gt;StartTrans();
		$ok = $db-&gt;Execute($stmt);
		$db-&gt;CompleteTrans();</pre>
<h3>5. REF CURSORs</h3>
<p>Oracle recordsets can be passed around as variables called REF Cursors. For example, in PL/SQL, we could define a function <i>open_tab</i> that returns a REF CURSOR in the first parameter:</p>
<pre>TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;

PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
	BEGIN
		OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
	END open_tab;</pre>
<p>In ADOdb, we could access this REF Cursor using the ExecuteCursor() function. The following will find  all table names that begin with &#8216;A&#8217; in the current schema:</p>
<pre>$rs = $db-&gt;ExecuteCursor("BEGIN open_tab(:refc,'A%'); END;",'refc');
while ($arr = $rs-&gt;FetchRow()) print_r($arr);</pre>
<p>The first parameter is the PL/SQL statement, and the second parameter is the name of the REF Cursor.</p>
<h3>6. In and Out Parameters</h3>
<p>The following PL/SQL stored procedure  requires an input  variable, and returns a result into an output variable:</p>
<pre>PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
	BEGIN
		output := 'I love '||input;
	END;</pre>
<p>The following ADOdb code allows you to call the stored procedure:</p>
<pre>$stmt = $db-&gt;PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;");
$input = 'Sophia Loren';
$db-&gt;InParameter($stmt,$input,'a1');
$db-&gt;OutParameter($stmt,$output,'a2');
$ok = $db-&gt;Execute($stmt);
if ($ok) echo ($output == 'I love Sophia Loren') ? 'OK' : 'Failed';</pre>
<p>PrepareSP( ) is a special function that knows about bind parameters. The main limitation currently is that IN OUT parameters do not work.</p>
<h4>Bind Parameters and REF CURSORs</h4>
<p>We could also rewrite the REF CURSOR example to use InParameter (requires ADOdb 4.53 or later):</p>
<pre>$stmt = $db-&gt;PrepareSP("BEGIN adodb.open_tab(:refc,:tabname); END;");
$input = 'A%';
$db-&gt;InParameter($stmt,$input,'tabname');
$rs = $db-&gt;ExecuteCursor($stmt,'refc');
while ($arr = $rs-&gt;FetchRow()) print_r($arr);</pre>
<h4>Bind Parameters and LOBs</h4>
<p>You can also operate on LOBs. In this example, we have IN and OUT parameters using CLOBs.</p>
<pre>$text = 'test test test';
	$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
	$stmt = $conn -&gt; PrepareSP($sql);
	$conn -&gt; InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB); # -1 means variable length
	$rs = '';
	$conn -&gt; OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
	$conn -&gt; Execute($stmt);
	echo "return = ".$rs."&lt;br&gt;";</pre>
<p>Similarly, you can use the constant OCI_B_BLOB to indicate that you are using BLOBs.</p>
<h4>Reusing Bind Parameters with CURSOR_SHARING=FORCE</h4>
<p>Many web programmers do not care to use bind parameters, and prefer to enter the SQL directly. So instead of:</p>
<pre>$arr = $db-&gt;GetArray("select * from emp where empno&gt;:emp", array('emp' =&gt; 7900));</pre>
<p>They prefer  entering the values inside the SQL:</p>
<pre>$arr = $db-&gt;GetArray("select * from emp where empno&gt;7900");</pre>
<p>This reduces Oracle performance because Oracle will reuse compiled SQL which is identical to previously compiled SQL. The above example with the values inside the SQL is unlikely to be reused. As an optimization, from Oracle 8.1 onwards, you can set the following session parameter after you login:</p>
<pre>ALTER SESSION SET CURSOR_SHARING=FORCE</pre>
<p>This will force Oracle to convert all such variables (eg. the 7900 value) into constant bind parameters, improving SQL reuse.</p>
<p>More <a href="http://phplens.com/adodb/code.initialization.html#speed">speedup tips</a>.</p>
<h3>7. Dates and Datetime in ADOdb</h3>
<p>There are two things you need to know about dates in ADOdb.</p>
<p>First, to ensure cross-database compability, ADOdb assumes that dates are returned in ISO format (YYYY-MM-DD H24:MI:SS).</p>
<p>Secondly, since Oracle treats dates and datetime as the same data type, we decided not to display the time in the default date format. So on login, ADOdb will set the NLS_DATE_FORMAT to &#8216;YYYY-MM-DD&#8217;. If you prefer to show the date and time by default, do this:</p>
<pre>$db = NewADOConnection('oci8');
$db-&gt;NLS_DATE_FORMAT =  'RRRR-MM-DD HH24:MI:SS';
$db-&gt;Connect($tns, $user, $pwd);</pre>
<p>Or execute:</p>
<pre>$sql = "ALTER SESSION SET NLS_DATE_FORMAT = 'RRRR-MM-DD HH24:MI:SS'";
$db-&gt;Execute($sql);</pre>
<p>If you are not concerned about date portability and do not use ADOdb&#8217;s portability layer, you can use your preferred date format instead.</p>
<h3>8. Database Portability Layer</h3>
<p>ADOdb provides the following functions for portably generating SQL functions    as strings to be merged into your SQL statements:</p>
<table align="center" border="1" width="75%">
<tr>
<td width="30%"><b>Function</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>DBDate($date)</td>
<td>Pass in a UNIX timestamp or ISO date and it will convert it to a date        string formatted for INSERT/UPDATE</td>
</tr>
<tr>
<td>DBTimeStamp($date)</td>
<td>Pass in a UNIX timestamp or ISO date and it will convert it to a timestamp        string formatted for INSERT/UPDATE</td>
</tr>
<tr>
<td>SQLDate($date, $fmt)</td>
<td>Portably generate a date formatted using $fmt mask, for use in SELECT        statements.</td>
</tr>
<tr>
<td>OffsetDate($date, $ndays)</td>
<td>Portably generate a $date offset by $ndays.</td>
</tr>
<tr>
<td>Concat($s1, $s2, &#8230;)</td>
<td>Portably concatenate strings. Alternatively, for mssql use mssqlpo driver,        which allows || operator.</td>
</tr>
<tr>
<td>IfNull($fld, $replaceNull)</td>
<td>Returns a string that is the equivalent of MySQL IFNULL or Oracle NVL.</td>
</tr>
<tr>
<td>Param($name)</td>
<td>Generates bind placeholders, using ? or named conventions as appropriate.</td>
</tr>
<tr>
<td>$db-&gt;sysDate</td>
<td>Property that holds the SQL function that returns today&#8217;s date</td>
</tr>
<tr>
<td>$db-&gt;sysTimeStamp</td>
<td>Property that holds the SQL function that returns the current timestamp (date+time).</td>
</tr>
<tr>
<td>$db-&gt;concat_operator</td>
<td>Property that holds the concatenation operator</td>
</tr>
<tr>
<td>$db-&gt;length</td>
<td>Property that holds the name of the SQL strlen function.</td>
</tr>
<tr>
<td>$db-&gt;upperCase</td>
<td>Property that holds the name of the SQL strtoupper function.</td>
</tr>
<tr>
<td>$db-&gt;random</td>
<td>Property that holds the SQL to generate a random number between 0.00 and 1.00.</td>
</tr>
<tr>
<td>$db-&gt;substr</td>
<td>Property that holds the name of the SQL substring function.</td>
</tr>
</table>
<p>ADOdb also provides multiple oracle oci8 drivers for different scenarios:</p>
<table align="center" border="1" width="75%">
<tr>
<td nowrap="nowrap"><b>Driver Name</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>oci805</td>
<td>Specifically for Oracle 8.0.5. This driver has a slower SelectLimit( ).</td>
</tr>
<tr>
<td>oci8</td>
<td>The default high performance driver. The keys of associative arrays returned in a recordset are upper-case.</td>
</tr>
<tr>
<td>oci8po</td>
<td>The portable Oracle driver. Slightly slower than oci8. This driver uses ? instead of :<i>bindvar</i> for binding variables, which is the standard for other databases. Also the keys of associative arrays are in lower-case like other databases.</td>
</tr>
</table>
<p>Here&#8217;s an example of calling the <i>oci8po</i> driver. Note that the bind variables use question-mark:</p>
<pre>$db = NewADOConnection('oci8po');
$db-&gt;Connect($tns, $user, $pwd);
$db-&gt;Execute("insert into atable (f1, f2) values (?,?)", array(12, 'abc'));</pre>
<p><a name="connecting"></a></p>
<h3>9. Connecting to Oracle</h3>
<p>Before you can use ADOdb, you need to have the Oracle client installed and setup the oci8 extension. This extension comes pre-compiled for Windows (but you still need to enable it in the php.ini file). For information on compiling the oci8 extension for PHP and Apache on Unix, there is an excellent guide at <a href="http://www.oracle.com/technology/tech/opensource/php/apache/inst_php_apache_linux.html">oracle.com</a>.</p>
<h4>Should You Use Persistent Connections</h4>
<p>One question that is frequently asked is should you use persistent connections to Oracle. Persistent connections allow PHP to recycle existing connections, reusing them after the previous web pages have completed. Non-persistent connections close automatically after the web page has completed. Persistent connections are faster because the cost of reconnecting is expensive, but there is additional resource overhead. As an alternative, Oracle allows you to pool and reuse server processes; this is called <a href="http://www.cise.ufl.edu/help/database/oracle-docs/server.920/a96521/manproc.htm#13132">Shared Server</a> (also known as MTS).</p>
<p>The author&#8217;s benchmarks suggest that using non-persistent connections and the Shared Server configuration offer the best performance. If Shared Server is not an option, only then consider using persistent connections.</p>
<h4>Connection Examples</h4>
<p>Just in case you are having problems connecting to Oracle, here are some examples:</p>
<p>a. PHP and Oracle reside on the same machine, use default SID, with non-persistent connections:</p>
<pre>$conn = NewADOConnection('oci8');
	$conn-&gt;Connect(false, 'scott', 'tiger');</pre>
<p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. &#8216;myTNS&#8217;, using persistent connections:</p>
<pre>$conn = NewADOConnection('oci8');
	$conn-&gt;PConnect(false, 'scott', 'tiger', 'myTNS');</pre>
<p>or</p>
<pre>$conn-&gt;PConnect('myTNS', 'scott', 'tiger');</pre>
<p>c. Host Address and SID</p>
<pre>$conn-&gt;connectSID = true;
	$conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'SID');</pre>
<p>d. Host Address and Service Name</p>
<pre>$conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre>
<p>e. Oracle connection string:</p>
<pre>$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
			(CONNECT_DATA=(SID=$sid)))";
	$conn-&gt;Connect($cstr, 'scott', 'tiger');</pre>
<p>f. ADOdb data source names (dsn):</p>
<pre>$dsn = 'oci8://user:pwd@tnsname/?persist';  # persist is optional
	$conn = ADONewConnection($dsn);  # no need for Connect/PConnect

$dsn = 'oci8://user:pwd@host/sid';
	$conn = ADONewConnection($dsn);

$dsn = 'oci8://user:pwd@/';   # oracle on local machine
	$conn = ADONewConnection($dsn);</pre>
<p>With ADOdb data source names, you don&#8217;t have to call Connect( ) or PConnect( ).</p>
<h3>10. Error Checking</h3>
<p>The examples in this article are easy to read but a bit simplistic because we ignore error-handling. Execute( ) and Connect( ) will return false on error. So a more realistic way to call Connect( ) and Execute( ) is:</p>
<pre>function InvokeErrorHandler()
{
global $db; ## assume global
    MyLogFunction($db-&gt;ErrorNo(), $db-&gt;ErrorMsg());
}
if (!$db-&gt;Connect($tns, $usr, $pwd)) InvokeErrorHandler();

$rs = $db-&gt;Execute("select * from emp where empno&gt;:emp order by empno",
                    array('emp' =&gt; 7900));
if (!$rs) return InvokeErrorHandler();
while ($arr = $rs-&gt;FetchRow()) {
    print_r($arr);
	echo "&lt;hr&gt;";
}</pre>
<p>You can retrieve the error message and error number of the last SQL statement executed from ErrorMsg( ) and ErrorNo( ). You can also <a href="http://phplens.com/adodb/using.custom.error.handlers.and.pear_error.html">define a custom error handler function</a>. ADOdb also supports throwing exceptions in PHP5.</p>
<h3>Handling Large Recordsets (added 27 May 2005)</h3>
<p>The oci8 driver does not support counting the number of records returned in a SELECT statement, so the function RecordCount()  is emulated when the global variable $ADODB_COUNTRECS is set to true, which is the default.  We emulate this by buffering all the records. This can take up large amounts of memory for big recordsets.  Set $ADODB_COUNTRECS to false for the best performance.This variable is checked every time a query is executed, so you can selectively choose which recordsets to count.</p>
<h3>11. Other ADOdb Features</h3>
<p><a href="http://phplens.com/lens/adodb/docs-datadict.htm">Schema generation</a>. This allows you to define a schema using XML and import it into different RDBMS systems portably.</p>
<p><a href="http://phplens.com/lens/adodb/docs-perf.htm">Performance monitoring and tracing</a>. Highlights of performance monitoring include identification of poor and suspicious SQL, with explain plan support, and identifying which web pages the SQL ran on.</p>
<h3>12. Download</h3>
<p>You can <a href="http://adodb.sourceforge.net/#download">download ADOdb from sourceforge</a>. ADOdb uses a BSD style license. That means that it is free for commercial use, and redistribution without source code is allowed.</p>
<h3>13. Resources</h3>
<ul>
<li>Oracle&#8217;s <a href="http://www.oracle.com/technology/pub/articles/php_experts/index.html">Hitchhiker Guide to PHP</a></li>
<li>OTN article on <a href="http://www.oracle.com/technology/pub/articles/deployphp/lim_deployphp.html">Optimizing PHP and Oracle</a> by this author.</li>
<li>Oracle has an excellent <a href="http://www.oracle.com/technology/tech/opensource/php/php_troubleshooting_faq.html">FAQ on PHP</a></li>
<li>PHP <a href="http://php.net/oci8">oci8</a> manual pages</li>
<li><a href="http://phplens.com/lens/lensforum/topics.php?id=4">ADOdb forums</a>.</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=22&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/11/using-adodb-with-php-and-oracle-an-advanced-tutorial/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL/XML Tutorial: SQL/XML, XQuery, and Native XML Programming Languages</title>
		<link>http://gudangberas.wordpress.com/2006/08/11/sqlxml-tutorial-sqlxml-xquery-and-native-xml-programming-languages/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/11/sqlxml-tutorial-sqlxml-xquery-and-native-xml-programming-languages/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 02:43:37 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/11/sqlxml-tutorial-sqlxml-xquery-and-native-xml-programming-languages/</guid>
		<description><![CDATA[Introduction Most web applications have connections to databases and use XML to transfer data from the database to the web application and vice versa. Every major database vendor has proprietary extensions for using XML with relational databases, but they take completely different approaches, and there is no interoperability between them. Developers need to be able [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=21&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Most web applications have connections to databases and use XML to transfer data from the database to the web application and vice versa. Every major database vendor has <a href="http://www.stylusstudio.com/altovaxml.html" title="AltovaXML Exposed">proprietary extensions</a> for using XML with relational databases, but they take completely different approaches, and there is no interoperability between them.  Developers need to be able to write applications that work for databases from multiple vendors.</p>
<p><a href="http://www.stylusstudio.com/xquery.html" class="list" title="XQuery Tools">XQuery</a> and <a href="http://www.stylusstudio.com/xml_database.html" class="list" title="Oracle XML Tools">SQL/XML</a> are two  standards that use declarative, portable queries to return XML by querying data. In both standards, the XML can have  any desired structure, and the queries can be arbitrarily complex. XQuery is XML-centric, while SQL/XML is SQL-centric.</p>
<p>SQL/XML is an extension of SQL that is part of ANSI/ISO SQL 2003. It lets SQL queries create XML structures with a few powerful XML publishing functions. For a SQL programmer, SQL/XML easy to learn because it involves only a few small additions to the existing SQL language. Since SQL is a mature language, there are a lot of tools and infrastructure for SQL. For instance, SQL/XML uses JDBC to return results, and there will soon be a standard API for XQuery. SQL also has functionality soon to be found in XQuery, such as <a href="http://www.stylusstudio.com/press/2005_08_02_xquery_update.html" title="XQuery Update">updates</a>  and stored procedures.</p>
<p><b>Note:</b> SQL/XML is completely different from Microsoft&#8217;s SQLXML, a proprietary technology used in SQL Server. The similarity in names has caused a great deal of confusion in the industry.</p>
<p>XQuery is a completely new query language that uses XML as the basis for its <a href="http://www.stylusstudio.com/xml_schema_editor.html" title="Schema Editor">data model</a> and <a href="http://www.stylusstudio.com/schema_aware.html" title="Schema-Aware XQuery">type system</a>. It is being developed in the XML Query Working Group, which is a part of the <a href="http://www.stylusstudio.com/w3c/" title="W3C Specifications">World Wide Web Consortium</a>.  In this paper, we characterize XQuery as a &#8220;Native XML Programming Language&#8221;. XQuery is based on XML in the same  way that SQL is based on the relational model or object oriented languages are based on the object oriented model  &#8211; XML is central to its type system, in which elements and attributes are just as fundamental as integers and  strings. Although XQuery per se has no concept of relational data, several products and many projects provide ways to query relational data using an <a href="http://www.stylusstudio.com/connect_for_sql_xml.html" title="Create XML Views of Relational Data Using SQL/XML">XML view of the database</a>, and the need to make this possible has influenced the design of XQuery throughout its development. XQuery allows you to work in the XML world no matter what type of data you&#8217;re working with &#8211; relational, XML or object data. XQuery is ideal for native XML programming. When used with XML views of relational data, it is also ideal for queries data that must represent results as XML, to query XML stored inside or outside the database, or to span relational and XML sources.</p>
<p>For queries based only on relational data, SQL/XML and XQuery have substantially similar functionality. However, the way in which a given task is done is quite different, since SQL/XML operates on the borderline between SQL and XML, and XQuery lives in a purely XML world. Even when the data is all relational, the two languages appeal to very different audiences &#8211; SQL/XML is very much an extension of SQL, designed for SQL programmers, and XQuery takes a purely XML view of the world. For queries that span relational and XML sources, XQuery has important advantages.</p>
<p>This talk uses a series of concrete queries written in each language to show the advantages of each. It explains why we need both languages, discussing the ways in which the languages differ and in which they overlap. It also explores the role of <a href="http://www.stylusstudio.com/learn_sql_xml.html" title="SQL/XML Tutorial">SQL/XML mappings as a way of creating XML views</a> for XQuery.</p>
<h2>XML and Relational &#8211; Opposites Attract</h2>
<p>XML and relational databases are tightly wed in most web applications, but a look at the two models shows that it is an unlikely marriage &#8211; though a necessary one. The relational model is based on two dimensional tables which have neither hierarchy nor significant order. XML is based on trees in which order is significant. In the relational model, neither hierarchy nor sequence may be used to model information; in XML, hierarchy and sequence are the main ways to represent information. Although this is one of the more fundamental differences between the two models, it is by no means the only one.</p>
<p>In many environments, the same information is represented in relational databases when it is stored or queried, but in XML when it is exchanged or displayed on web pages. These representations are often completely different due to the differences in the models.</p>
<p>On web pages, XML is useful because the structure of XML closely matches the structure used to display the same information in HTML. If you look at web pages, they often use a distinctly hierarchical structure to present data for users &#8211; after all, users don&#8217;t want to look at a bunch of tables and do joins in their head. But most of the data for these web pages comes from relational databases, and needs to be converted to appropriate XML hierarchies.</p>
<p>For web messages, the format of a web message is often specified by a standards organization or a trade partner, and these formats are generally hierarchical. Again, the data for a web message generally comes from relational data, and the consumer of a web message often needs to put data into a relational database.</p>
<p>For instance, suppose a consulting company needs to represent a set of projects and the companies for whom the projects are being done. In a relational database, this might be represented by the following tables:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_projects.gif" alt="Project Relational Database Table" height="138" width="360" /></p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_customers.gif" alt="Customer Relational Database Table" height="144" width="381" /></p>
<p>In SQL, if we want to see the projects associated with each customer, we would do the following query:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_query.gif" alt="SQL Query joining Project and Customer Tables" height="69" width="253" /></p>
<p>Here is the output of the above SQL query:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_query_output.gif" alt="The SQL Query's Output" height="95" width="506" /></p>
<p>Suppose we want to translate this information into XML in order to <a href="http://www.stylusstudio.com/xslt_debugger.html" title="XSL Debugger">publish it to the Web</a>, in a document, or in a web message. Like most XML applications, we will leverage the hierarchy of XML to express relationships, listing the projects for each customer within the element that represents the customer:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_fragment.gif" alt="An XML fragment" height="282" width="467" /></p>
<p>Note that in the original SQL tables, each customer is represented only once. This is also true of the XML. The SQL result set, however, contains multiple rows for a given customer if that customer is associated with more than one project, and these rows contain duplicate information. Translating this result set into the desired XML is tedious for the programmer. And just as a single relational database may be used with an infinite number of queries, it may also be used to create an infinite number of XML documents with different structures. Today, many programmers spend a great deal of time doing this kind of translation.</p>
<h2>XML and Relational: Four Approaches</h2>
<p>XML applications that use relational data can choose from four approaches, each with distinct advantages and disadvantages. The first three of these are compared in some detail, with code samples, in [SQL/XML-JDBC].</p>
<p>The programmer can use JDBC or ODBC together with SAX or DOM and perhaps <a href="http://www.stylusstudio.com/xslt.html" class="list" title="Tools for XSLT">XSLT</a> to transform the results of SQL queries to XML. For instance, the program might first query for customers, then perform an additional query to find the projects associated with each customer. This is inefficient because of the number of queries required. Another approach would be to use SQL to create a table that lists customers and their projects, and pick through the rows to determine when a row represents a new customer. This requires more code, but is more efficient. Both of these approaches require significant amounts of tedious code, but they are often used when database independence is important.</p>
<p>The programmer can use the XML extensions provided by the major database vendors. These are based on several different approaches. Some of these are simpler to use or maintainable than others, but they all make the task easier. However, since these extensions are all proprietary, they are not an option when a database-independent solution is needed.</p>
<p>The programmer can use SQL/XML, which is part of SQL 2003. For a SQL programmer, this approach requires little new learning &#8211; a small set of XML publishing functions have been added to SQL to allow queries to create any desired XML structure. This approach will be explored with examples in the next section. SQL/XML is being supported by Oracle and IBM, but not by Microsoft. Database-independent implementations of SQL/XML are also available, and can be used with any major relational database. SQL/XML can be used with traditional database APIs such as JDBC.</p>
<p>The programmer can use XQuery, a native XML query language. Since XQuery is a new language, it requires more learning for SQL programmers, but it is likely to be more natural for <a href="http://www.stylusstudio.com/xmldev/" title="XML DEV">XML programmers</a>. Unlike SQL/XML, XQuery is optimal for processing XML, and it is also particularly good for applications that must process XML together with relational data, with full support for XML. Most of the major database vendors intend to support XQuery. The first standardized API for XQuery, XQuery for Java (JSR 225), is now being developed under Java Community Process, and is expected to be available shortly after the XQuery Recommendation is released.</p>
<h2>SQL/XML</h2>
<p>SQL/XML refers to the XML extensions of SQL. These are developed by INCITS H2.3, with participation from Oracle, IBM, Microsoft (which does not plan to implement SQL/XML), Sybase, and DataDirect Technologies. In SQL 2003, these extensions include:</p>
<ul>
<li>XML Publishing Functions</li>
<li>The XML Datatype</li>
<li>Mapping Rules</li>
</ul>
<p>The XML Publishing Functions are the part that are directly used in a SQL query. The XML Datatype governs the result of a query, and the Mapping Rules determine how SQL data or metadata is represented as XML.</p>
<h2>XML Publishing Functions</h2>
<table border="1" cellspacing="0">
<tr>
<td width="100">xmlelement()</td>
<td>Creates an XML element, allowing the name to be specified.</td>
</tr>
<tr>
<td width="100">xmlattributes()</td>
<td>Creates XML attributes from columns, using the name of each<br />
column as the name of the corresponding attribute.</td>
</tr>
<tr>
<td width="100">xmlroot()</td>
<td>Creates the root node of an XML document.</td>
</tr>
<tr>
<td width="100">xmlcomment()</td>
<td>Creates an XML comment.</td>
</tr>
<tr>
<td width="100">xmlpi()</td>
<td>Creates an XML processing instruction.</td>
</tr>
<tr>
<td width="100">xmlparse()</td>
<td>Parses a string as XML and returns the resulting XML structure.</td>
</tr>
<tr>
<td width="100">xmlforest()</td>
<td>Creates XML elements from columns, using the name of each<br />
column as the name of the corresponding element.</td>
</tr>
<tr>
<td width="100">xmlconcat()</td>
<td>Combines a list of individual XML values to create a<br />
single value containing an XML forest.</td>
</tr>
<tr>
<td width="100">xmlagg()</td>
<td>Combines a collection of rows, each containing a single XML value,<br />
to create a single value containing an XML forest.</td>
</tr>
</table>
<p>Let&#8217;s compare a traditional SQL query with one that uses an XML publishing function. Here is a traditional SQL query that shows customers and their associated projects:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_simple_query.gif" alt="A simple SQL Query" height="37" width="284" /></p>
<p>Here is is an excerpt of the result:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_simple_output.gif" alt="An excerpt of the SQL query results" height="97" width="230" /></p>
<p>Now let&#8217;s wrap the result in XML elements using xmlelement(), one of the publishing functions:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xmlelement.gif" alt="Wrapping XML elements using SQL/XML's xmlelement() function" height="78" width="323" /></p>
<p>Each row in the result contains one Customer element. A Customer element looks like this:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_customer.gif" alt="The SQL query results in XML" height="80" width="254" /></p>
<p>xmlforest() is an XML publishing function that creates elements from a list of columns, using the name of the column as the name of the element. Using xmlforest() simplifies many queries significantly. For instance, the following query is equivalent to the previous one:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_forest.gif" alt="The SQL/XML xmlforest() function" height="52" width="425" /></p>
<p>Now suppose we want to show customers and the projects associated with them. This is easily done with the following SQL query:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_join.gif" alt="A SQL Join" height="66" width="269" /></p>
<p>However, the result of this query is that shown in the CustomerProject table in the previous section, with one row for each Customer/Project pair. If a customer is associated with more than one project, there will be a row for that customer for each project. Here is a SQL/XML query that creates the XML equivalent to that table:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_advanced_query.gif" alt="Advanced SQL/XML Statement" height="80" width="539" /></p>
<p>Here are the results of this query:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_advanced_query_results.gif" alt="Advanced SQL/XML Statement Results" height="268" width="293" /></p>
<p>This is a straightforward XML translation of the that a SQL result set shown in the previous section, but for most XML applications it is not what we would want. Instead, we want to represent each customer once, with a list of that customer&#8217;s projects, as shown in the XML output in the previous section. In SQL/XML, this can be done by using a sub-query. Here is a subquery that retrieves the <a href="http://www.stylusstudio.com/xml_project.html" title="XML Project Window">projects</a> associated with each customer. In this subquery we use xmlattributes(), an XML publishing function that creates attributes within an element. The names of the attributes are taken from the names of the columns.</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xmlattributes.gif" alt="Advanced SQL/XML query with xmlattribute() function" height="86" width="296" /></p>
<p>Here is the output of the above sub-query when c.CustId is 4:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_output.gif" alt="SQL/XML query output" height="99" width="220" /></p>
<p>This output contains two rows, with one element in each row. Subqueries in SQL/XML are allowed to return only one row; therefore, to return more than one row of values in a SQL/XML subquery, they must be combined to form a single value. xmlagg() is an XML publishing function that produces a forest of elements by collecting the XML values that are returned from multiple rows and concatenating the values to make one value. Here is a query that uses the above subquery to create the XML output from the previous section:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_complete_query.gif" alt="A very common SQL/XML pattern used to create XML hierarchies using SQL/XML." height="172" width="413" /></p>
<p>The above query illustrates a very common pattern used to create XML hierarchies using SQL/XML.</p>
<h2>The XML Datatype</h2>
<p>The XML Datatype is a datatype in the same way that integer, date, or CLOB are datatypes in SQL. Since SQL/XML allows a query to create XML instances, there must be a datatype that corresponds to these instances.</p>
<p>It is anticipated that the XML Datatype will be supported in JDBC 4.0. It is too early to say exactly how it will be used in that specification, but it is likely that it will retrieve XML values much like other values, and that XML values can be retrieved as text, DOM, or SAX events. This is the approach currently taken by <a href="http://www.stylusstudio.com/api/sqlxml/index-all.htm">DataDirect Connect for SQL/XML</a>. To illustrate this, let&#8217;s use a SQL/XML query to create a table with two columns, an integer containing the CustId and an XML column containing the XML output from the previous query. Here is the query:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_sqlxmlstring.gif" alt="SQL/XML statement using xmlelement(), xmlattributes(), and xmlforest()" height="171" width="411" /></p>
<p>Suppose the above query is in a string called sqlxmlString. Then the following <a href="http://www.stylusstudio.com/java_code_generation.html" title="Java Code Generation">Java code</a> can be used to execute the query and retrieve values.</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_java_code.gif" alt="Java code can be used to execute  the query and retrieve data" height="186" width="405" /></p>
<p>The XML Type also plays a second important role &#8211; <a href="http://www.stylusstudio.com/xml_database.html" title="Oracle XML Tools">relational databases</a> now routinely store XML in individual column, and the XML Type provides a standard type for such columns, which is useful both in SQL and in JDBC.</p>
<h2>SQL/XML Mapping Rules</h2>
<p>The XML publishing functions use SQL values to create XML values, and these XML values have W3C XML Schema types. When we discussed the XML publishing functions, we did not address specifically how the XML representation is determined. The mapping rules of SQL/XML describe in excruciating detail <a href="http://www.stylusstudio.com/db_to_xml_mapper.html" class="list" title=" SQL/XML Editor Mapping">how SQL values can be mapped to and from XML values</a>, and how SQL metadata can be mapped to and from <a href="http://www.stylusstudio.com/xml_schema.html" class="list" title="XML Schema Tools">W3C XML Schemas</a>. To give a flavor for the level of detail in which this is specified, here are the equivalent headings from the SQL/XML specification&#8217;s table of contents:</p>
<ul>
<li>Mapping SQL character sets to Unicode.</li>
<li>Mapping SQL &lt;identifier&gt;s to XML Names.</li>
<li>Mapping SQL data types (as used in SQL-schemas to define SQL-schema objects such as columns) to XML Schema data types.</li>
<li>Mapping values of SQL data types to values of XML Schema data types.</li>
<li>Mapping an SQL table to an XML document and an XML Schema document.</li>
<li>Mapping an SQL schema to an XML document and an XML Schema document.</li>
<li>Mapping an SQL catalog to an XML document and an XML Schema document.</li>
<li>Mapping Unicode to SQL character sets.</li>
<li>Mapping XML Names to SQL &lt;identifier&gt;s.</li>
</ul>
<p>These mappings can be parameterized in several ways, including the target namespace for the result, whether to handle nulls using xsi:nil or absence, and whether to map a table to a single element or a forest of elements. Here is an XML representation of the <a href="http://www.stylusstudio.com/customers/" title="Customer List">Customers</a> table shown earlier, using a single element for each table and no target namespace:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_mapping_rules.gif" alt="SQL/XML Mapping Rules" height="238" width="285" /></p>
<p>Here is an XML representation of the same table using a forest of elements to represent each table:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_representation.gif" alt="XML representation of the same table using a forest of elements to represent each table" height="214" width="281" /></p>
<p>These mappings are also defined on the metadata level. For instance, SQL/XML defines how the datatypes of SQL are represented in the equivalent XML Schema. Each SQL type is derived from an equivalent built-in W3C XML Schema type. Where needed, facets are used to represent constraints added to those of the base type:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_schema.gif" alt="SQL/XML defines how SQL datatypes  are represented in the equivalent XML Schema" height="157" width="347" /></p>
<p>As mentioned above, there are two ways to represent null values. Suppose the City column may have null values. Here is a row in the Customer&#8217;s table that represents a null value using the first strategy, a nilled element:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_nil_value.gif" alt="Representing nil values in XML" height="114" width="253" /></p>
<p>Here is a row that uses the second strategy, an absent element:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_nill_absent.gif" alt="Absent XML element nill value" height="97" width="216" /></p>
<h2>XQuery and Native XML Programming</h2>
<p>The XQuery language was designed for querying or processing XML. Just as a traditional SQL query takes a set of tables as input and returns an XML table as its result, XQuery takes sequences of XML nodes as input and evaluates to a sequence of XML nodes. However, from the very beginning, XQuery was designed to allow <a href="http://www.stylusstudio.com/xml_views.html" title="XML Editing Views">XML views</a> of <a href="http://www.stylusstudio.com/convert_to_xml.html" title="Convert to XML Tools">non-XML data</a>, as well as serialized forms of non-XML data. The reason for this is simple: XML is used to represent almost any conceivable kind of information, and it is easiest to integrate information if it is given a common view.</p>
<p>If everything looks like a nail, all you need is a hammer. Conventional Internet applications often store and query data using SQL, process data using Java or C#, and exchange data as XML. Using XQuery, it is possible to store, query, process, and exchange data as XML. This eliminates some of the mismatches that cause complications when working with XML in other environments.</p>
<h2>Native XML Programming</h2>
<p>XQuery is a language designed for <a href="http://www.stylusstudio.com/videos/ddxqdemo/datadirectxquery.html" title="Using DataDirect XQuery with Stylus Studio">integrating data from multiple sources</a>, including XML sources like documents or web messages and databases. It does this by leveraging the ability of XML to model virtually any kind of data. To query anything with XQuery, it must be presented as though it were XML, either by serializing it as XML or by creating an XML view of the data through some form of middleware. For relational data, most systems use the SQL/XML mappings for the XML view, since they are quite suitable and have been specified in detail.</p>
<p>XML is the basis of XQuery&#8217;s type system and data model. The fundamental types of XQuery include the kinds of nodes found in XML documents: document nodes, elements, attributes, processing instructions, comments, and text nodes. XQuery also supports the built-in datatypes of W3C XML Schema for representing integers, strings, dates, and other datatypes &#8211; these built-in datatypes are predefined in XQuery, and are available with or without a schema.</p>
<p>Most modern programming languages provide some form of complex user-defined types, such as structures or objects. In XQuery, the only complex types are XML documents, elements, attributes, and W3C XML Schema complex types. There is no need to write a schema to create and manipulate complex XML structures in XQuery. However, if a query needs to ensure consistent use of the types in a schema, a schema may be imported into a query. This has an effect analogous to importing structure or class definitions in an object oriented language.</p>
<p>Programs tend to revolve around data, and the complex datatypes used in a language have a profound effect on the way that a language is used. As a result, languages are sometimes identified by the way they represent complex data; for instance, there are object-oriented languages and relational query languages. In this sense, XQuery can be considered Native XML Programming Language. XSLT and <a href="http://www.stylusstudio.com/xpath.html" class="list" title="Tools for XPath">XPath</a> are also Native XML Programming Languages. Most other languages used to process XML, including Java, C#, Perl, and Python are not. SQL/XML is fundamentally an extension to a relational query language, providing a bridge to XML.</p>
<p>The concept of a Native XML Programming Language is new, and many XML programmers are used to thinking of XML in terms of the constructs used in the languages with which they process XML. On XML-related mailing lists it is reasonably common to see beginners assert that XML is fundamentally relational or object-oriented, and even sophisticated XML programmers have been known to assert that XML is just text. In fact, the phrase &#8220;XML is Unicode with pointy brackets&#8221; has come to identify a vocal part of the XML community.</p>
<h2>XML is not Objects!</h2>
<p>An XML document can be represented using objects, and this is precisely the approach taken by DOM and JDOM. An <a href="http://www.stylusstudio.com/xml_parsers.html" title="XML Validator, XML Parser">XML parser</a> can be used to create an appropriate object representation of an XML document without involving the programmer. However, the fundamental types of XML are not fundamental in object oriented languages, so casting and conversion is frequently required. Similarly, the basic notions of hierarchy and containment are not directly supported in the object oriented model, so explicit navigation is often required. This causes significant work for the programmer.</p>
<p>Adam Bosworth pointed this out with the following example. Suppose a programmer wants to compute price/earnings ratios from an XML feed. An individual stock might be represented as follows:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_object.gif" alt="Stock price" height="113" width="250" /></p>
<p>To compute the price/earnings ratio, we use the formula &#8220;pe = price / (revenues &#8211; expenses)&#8221;. To do this with the DOM, we also need to parse the XML, navigate to the places where this information is found, and convert the text of the document to the appropriate datatype. Here is the DOM code Adam provides for this:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_dom.gif" alt="Performing calculations using XML data and the Document Object Model" height="70" width="364" /></p>
<p>This solution would have been much messier if Adam had not used the path expressions of XPath, a simple Native XML language. In XQuery, path expressions are part of the language, and numeric conversions are automatically done for untyped data. If the data is validated against a schema, the types assigned by the schema are used. This makes it possible to solve the same problem much more simply:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_solution.gif" alt="For XML/Data centric applications, object-oriented representation of an XML document imposes unneeded overhead." height="43" width="429" /></p>
<p>For XML-centric applications, an object-oriented representation of an XML document imposes unneeded overhead that complicates programs.</p>
<h2>XML is not just text!</h2>
<p>To many intelligent and articulate XML programmers, &#8220;XML is just Unicode with pointy brackets&#8221; is almost a statement of faith. Predictably, these people also complain that it is difficult to process XML without a parser. For instance, Joe Gregorio notes that in XML this document:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_text.gif" alt="Sample XML Document" height="128" width="427" /></p>
<p>must be treated as identical to this document:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_doc.gif" height="111" width="544" /></p>
<p>To many of us, this is merely an indication that XML must first be parsed and converted to an appropriate data model before it can easily be processed. In fairness to Joe, he initially assumed this as well, but then changed his mind:</p>
<p><i>More XML experience is gained by yours truly and on many occasions I have found myself pining for the ability to do regular expression processing of XML. If only the pathologies of the above examples didn&#8217;t exist then I could use a combination of XPath and regular expressions to perform XML manipulations that would be easier for me to implement, understand and maintain.</i></p>
<p><i>Today I reached the breaking point. The problem isn&#8217;t with regular expressions, the problem is with XML. The pathologies in XML that preclude the use of regular expressions are just that, pathologies, and ones that need to be excised.</i></p>
<p>As a result, he suggests that XML be subsetted as follows:</p>
<ul>
<li>All namespace declarations must be done in the root element.</li>
<li>Never a declaration for the &#8220;&#8221; namespace. I.e. if an element sits the &#8220;&#8221; namespace then the element name will never have a namespace qualifier.</li>
<li>No CDATA sections.</li>
<li>No DTDs</li>
</ul>
<p>The above restrictions would make it easier for a programmer to work with XML without using an XML parser, but it is unlikely that the XML community will replace XML with something along these lines &#8211; especially since there are important usage scenarios for features like <a href="http://www.stylusstudio.com/dtd.html" class="list" title="DTD Tools">DTDs</a>, schemas, and the ability to build compound documents without knowing, at the root level, all of the namespaces that may be used in a document. More to the point, Joe&#8217;s original reason for trying to solve these problems with XPath and regular expressions was that the standard APIs do not make it easy to solve many simple problems. Looking at his article as a whole, and other articles he has written, we believe that many of these difficulties are caused by the same kind of semantic mismatches that a Native XML Programming Language is designed to solve.</p>
<p>In this paper, we assume that XML will remain as is, and that for general processing, the best approach is to use an XML parser to build a data model instance from the XML documents, and query the data model instance. Not everybody believes this is the best approach. Tim Bray, one of the editors of the original XML specification, objects to the Native XML Programming solution because he objects to the notion of an XML data model:</p>
<p><i>The notion that there is an &#8220;XML data model&#8221; is silly and unsupported by real-world evidence. The definition of XML is syntactic: the &#8220;Infoset&#8221; is an afterthought and in any case is far indeed from being a data model specification that a programmer could work with. Empirical evidence: I can point to a handful of different popular XML-in-Java APIs each of which has its own data model and each of which works. So why would you think that there&#8217;s a data model there to build a language around?</i></p>
<p>Tim first says that there is no data model for XML, then argues that there are several. The differences among these data models, while annoying, are not great, and could have been avoided if XML had had a full-fledged data model. The differences between the DOM data model and the XPath data model are well known in the XML world. XQuery, XPath, and XSLT now use one common data model, which can represent both XML and the XML Schema datatypes. Although it would have been convenient if XML had defined a data model, there is no requirement that the data model used by a Native XML Programming Language be the same as any particular data model used in a <a href="http://www.stylusstudio.com/api/" title="Stylus Studio APIs">Java API</a>. As long as the data model supports the structure of XML directly, without losing or adding information in violation of the XML spec, it can be used as the basis for processing.</p>
<p>Tim also suggests that XML is &#8220;syntactic&#8221;, as though this implies that there is no data model. This implies that syntax and structure are opposites, which is rather surprising, since the purpose of a syntax is to describe the structure of a language. In the XML Recommendation, the structure that corresponds to a data model is called the logica structure:</p>
<p><i>Each XML document has both a logical and a physical structure. [. . .] Logically, the document is composed of declarations, elements, comments, character references, and processing instructions, all of which are indicated in the document by explicit markup.</i></p>
<p>Like most modern computer languages, XML uses a BNF to describe the syntactic representation of these structures. For instance, here is a production from the XML Recommendation:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_tim_bray.gif" alt="XML uses a BNF to describe the syntactic representation of XML structures" height="27" width="392" /></p>
<p>The XML Recommendation is largely a description of these logical structures and the relationships among them. For instance, consider the following text:</p>
<p><i>Example: The element structure of an XML document may, for validation purposes, be constrained using element type and attribute-list declarations. An element type declaration constrains the element&#8217;s content.</i></p>
<p>Element, XML document, and content all refer to logical structures that are represented in the BNF. These logical structures, taken together with the relationships among them as described in the XML Recommendation, come very close to being a data model, but the data model was not fully described.</p>
<p>The whole point of parsing is to create structures from a sequence of characters, using a grammar to determine which structures to create. When a parser is used to interpret the characters of a program in Java, it creates an Abstract Syntax Tree. When it is used to interpret the characters of XML, it creates a data model instance. We use parsers because (1) the parsed structure is more convenient for further processing, (2) the parsed structure distinguishes information from noise, eliminating differences in the character representation that are not significant in the relevant model, and (3) the parsed structure can fill in information not explicitly represented in the serialized form.</p>
<p>However, an XML parser is not enough. A parser creates a convenient representation of XML. We need a Native XML Programming Language to provide convenient processing of this XML.</p>
<h2>What should a Native XML Programming Language do?</h2>
<p>A Native XML Programming Language must provide the fundamental operations needed for XML. Some of these operations are required because of the structure of XML itself.</p>
<p>A Native XML Programming Language should be able to easily find anything in an XML structure. XQuery, like XSLT, uses XPath for this purpose. <a href="http://www.stylusstudio.com/xquery_primer.html" title="Learn XQuery">Every XPath expression is also an XQuery expression</a>. For instance, if the variable $cust is bound to a Customers element that contains the rows of a relational table, represented using the SQL/XML mappings, then the following path expression finds all the CustIds from that table:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_path%20expression.gif" alt="Path Expression" height="31" width="187" /></p>
<p>A Native XML Programming Language should be able to easily create any XML structure. XQuery uses the syntax of XML for this purpose. For instance, the following XQuery expression creates a Customer element:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_structure.gif" alt="XML Structure" height="70" width="313" /></p>
<p>When XQuery uses the syntax of XML, a curly brace escapes to the syntax of XQuery, allowing dynamic expressions to be inserted. Here is an example that creates a customer with a new unique identifier:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xquery_syntax.gif" alt="XQuery Syntax" height="72" width="380" /></p>
<p>A Native XML Programming Language should be able to easily combine and restructure information from XML sources, operating at the logical level without requiring the programmer to think about the internal representation of the XML. For instance, if we are operating on the SQL/XML views of the customers database, the following XQuery combines customers and projects to show the name of a customer and all projects associated with that customer:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_query_syntax.gif" alt="Native XML Programming Language" height="114" width="351" /></p>
<p>A Native XML Programming Language should be able to easily use XML data in expressions. For instance, arithmetic operations should be able to work directly with XML content, observing the data types of typed data and converting appropriately when they encounter untyped data. It should be able to leverage schemas that have been imported into a query, but work well on XML structures for which no schema has been imported.</p>
<p>In short, a Native XML Programming Language should be able to work with XML the way XML users think of it, easily performing the kinds of tasks that XML users need to have done. XQuery attempts to do just that, based on the usage scenarios we gathered in XML Query Use Cases.</p>
<h2>XQuery and SQL/XML Views</h2>
<p>Some people seem to believe that the purpose of XQuery is largely the same as that of SQL/XML &#8211; to allow XML structures to be created from relational data. Although XQuery is useful for this task, it has relatively few advantages over SQL/XML when this is all that is required. The reason for this is simple: SQL is a language designed for handling SQL data sources, and it does that very well. Adding XML publishing functions to SQL is a simple way to let it create XML. However, it is interesting to note that the SQL/XML views of relational tables have a very constrained structure, and XQuery performed on such views is generally quite similar to the equivalent SQL/XML.</p>
<p>For instance, let&#8217;s write an XQuery equivalent to the last SQL/XML query we used. This query will operate on a SQL/XML view of the relational tables. The Projects table is represented as follows:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xquery_equivalent.gif" alt="XQuery equivalent of SQL/XML statements" height="188" width="199" /></p>
<p>The Customers table is represented as follows:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xml_query_fragment.gif" height="116" width="270" /></p>
<p>We want to rename these elements and create a representation that shows customers together with their projects. The output should look like this:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_desired_output.gif" alt="Desired XML output" height="113" width="336" /></p>
<p>Here is an XQuery that creates the desired output:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xquery_solution.gif" alt="XML Query solution" height="201" width="408" /></p>
<p>Let&#8217;s compare this XQuery to the SQL/XML query from a prior section:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xquery_comparison.gif" alt="SQL/XML and XQuery comparison" height="253" width="547" /></p>
<p>In this example, as in most such examples, it is hard to argue that either solution is particularly superior to the other. Either SQL/XML or XQuery handle such tasks quite well. The real strength of XQuery is in the ability to easily process XML, whether or not relational data is being processed, including the XML that is frequently stored in columns of relational databases and the XML of web messages. Since XQuery also works well on SQL/XML views of relational data, it is particularly useful when both XML data and relational data must be used in processing. This is explored in the next section.</p>
<h2>Spanning Sources: XQuery, Web Messages, and Databases</h2>
<p>XQuery, when combined with a SQL/XML view of a relational database, is extremely good for processing XML together with relational data. This is a very common requirement in many environments, including <a href="http://www.stylusstudio.com/ws_tester.html" title="Web Service Testing Tools">web message processing environments</a>. To illustrate this, we will use Example 1 from the SOAP Primer. The task is as follows: an incoming message requests a flight to Los Angeles departing from New York as follows:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_web_services.gif" alt="Incoming SOAP message" height="185" width="477" /></p>
<p>According to the SOAP Primer, the proper response is to point out that there are three airports that depart from New York, so that the user can be prompted to pick one. Here is the desired output:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_web_service_example.gif" alt="XQuery and Web Services Example" height="95" width="460" /></p>
<p>Reading between the lines, we assume that there is a database somewhere that lists the airports for each city. The SQL/XML view of the airports table might look like this:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_sample_data.gif" alt="Sample XML Data" /></p>
<p>We will assume that when there is only one airport for a city, the output should simply list that city, and that an error should be raised if there is no airport for a given city. The following XQuery handles all three of these cases:</p>
<p><img src="http://www.stylusstudio.com/images/figures/sql_xml_xquery_webservice_example.gif" height="242" width="495" /></p>
<p>Note that this code operates at a level very close to the application domain, rather than navigating XML documents and converting from XML to appropriate types in the host language. XML data sources and relational data sources are treated in the same way &#8211; to the query, they both look like XML documents.</p>
<h2>XQuery for Java (JSR 225)</h2>
<p>SQL programmers are used to using APIs such as ODBC or JDBC to set up the environment, execute queries, and do processing in the business domain using the data returned by a query. Similar APIs are expect to emerge for XQuery. The first standard API for this purpose is now being developed under Java Community Process. It is known as XQuery for Java (XQJ), or JSR 225.</p>
<p>Significantly, the requirements of JSR 225 ensure that both XML documents and XML views of databases will be supported, and the results of a query can be processed using JAXP and SAX</p>
<h2>SQL/XML and XQuery: Do we need both?</h2>
<p>Although SQL/XML and XQuery are both XML query standards, they are based on quite different models, and fit best in different architectures. SQL/XML fits cleanly into the relational model as a reasonably small extension to traditional SQL. This means that it works well in traditional SQL environments, providing full access to the existing SQL language, including features like updates and full-text queries that are not going to be part of XQuery 1.0. One of the other advantages of using SQL as a basis is that database manufacturers have many years of experience in optimizing SQL queries, which means that many of the optimization issues are well known. Also, it has existing APIs, including ODBC and JDBC. In short, SQL/XML provides the functionality needed for creating XML from relational data while still fitting cleanly into the existing SQL environment. SQL/XML implementations will be available from Oracle and IBM, but not Microsoft, and a cross-database implementation is available from DataDirect Technologies. Oracle&#8217;s implementation also provides functionality for querying and processing XML as well as SQL, and there is some interest in adding extensions along these lines to SQL/XML. Some members of the SQL/XML task force would also like to see parts of XQuery added to SQL/XML.</p>
<p>XQuery fits more cleanly into the XML environment, providing Native XML Programming for both XML sources and non-XML sources accessed via an XML view. It is well designed for combining data from multiple sources, and is very efficient for a variety of XML programming tasks. However, XQuery is a brand new language &#8211; in fact, at the time of writing, XQuery 1.0 is merely a Working Draft, not likely to emerge until the second half of 2004. There is a great deal of enthusiasm surrounding XQuery, most major database vendors have announced support for it, and there is a great deal of research on optimizing XQuery. However, XQuery is a much younger language, the industry has little experience optimizing it, and it lacks some features, including updates and fulltext, that are very important for some kinds of tasks. Also, the API for XQuery, XQuery for Java (JSR 225) is just now being developed.</p>
<h2></h2>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=21&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/11/sqlxml-tutorial-sqlxml-xquery-and-native-xml-programming-languages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_projects.gif" medium="image">
			<media:title type="html">Project Relational Database Table</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_customers.gif" medium="image">
			<media:title type="html">Customer Relational Database Table</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_query.gif" medium="image">
			<media:title type="html">SQL Query joining Project and Customer Tables</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_query_output.gif" medium="image">
			<media:title type="html">The SQL Query's Output</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_fragment.gif" medium="image">
			<media:title type="html">An XML fragment</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_simple_query.gif" medium="image">
			<media:title type="html">A simple SQL Query</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_simple_output.gif" medium="image">
			<media:title type="html">An excerpt of the SQL query results</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xmlelement.gif" medium="image">
			<media:title type="html">Wrapping XML elements using SQL/XML's xmlelement() function</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_customer.gif" medium="image">
			<media:title type="html">The SQL query results in XML</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_forest.gif" medium="image">
			<media:title type="html">The SQL/XML xmlforest() function</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_join.gif" medium="image">
			<media:title type="html">A SQL Join</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_advanced_query.gif" medium="image">
			<media:title type="html">Advanced SQL/XML Statement</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_advanced_query_results.gif" medium="image">
			<media:title type="html">Advanced SQL/XML Statement Results</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xmlattributes.gif" medium="image">
			<media:title type="html">Advanced SQL/XML query with xmlattribute() function</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_output.gif" medium="image">
			<media:title type="html">SQL/XML query output</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_complete_query.gif" medium="image">
			<media:title type="html">A very common SQL/XML pattern used to create XML hierarchies using SQL/XML.</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_sqlxmlstring.gif" medium="image">
			<media:title type="html">SQL/XML statement using xmlelement(), xmlattributes(), and xmlforest()</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_java_code.gif" medium="image">
			<media:title type="html">Java code can be used to execute  the query and retrieve data</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_mapping_rules.gif" medium="image">
			<media:title type="html">SQL/XML Mapping Rules</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_representation.gif" medium="image">
			<media:title type="html">XML representation of the same table using a forest of elements to represent each table</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_schema.gif" medium="image">
			<media:title type="html">SQL/XML defines how SQL datatypes  are represented in the equivalent XML Schema</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_nil_value.gif" medium="image">
			<media:title type="html">Representing nil values in XML</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_nill_absent.gif" medium="image">
			<media:title type="html">Absent XML element nill value</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_object.gif" medium="image">
			<media:title type="html">Stock price</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_dom.gif" medium="image">
			<media:title type="html">Performing calculations using XML data and the Document Object Model</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_solution.gif" medium="image">
			<media:title type="html">For XML/Data centric applications, object-oriented representation of an XML document imposes unneeded overhead.</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_text.gif" medium="image">
			<media:title type="html">Sample XML Document</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_doc.gif" medium="image" />

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_tim_bray.gif" medium="image">
			<media:title type="html">XML uses a BNF to describe the syntactic representation of XML structures</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_path%20expression.gif" medium="image">
			<media:title type="html">Path Expression</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_structure.gif" medium="image">
			<media:title type="html">XML Structure</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xquery_syntax.gif" medium="image">
			<media:title type="html">XQuery Syntax</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_query_syntax.gif" medium="image">
			<media:title type="html">Native XML Programming Language</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xquery_equivalent.gif" medium="image">
			<media:title type="html">XQuery equivalent of SQL/XML statements</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xml_query_fragment.gif" medium="image" />

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_desired_output.gif" medium="image">
			<media:title type="html">Desired XML output</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xquery_solution.gif" medium="image">
			<media:title type="html">XML Query solution</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xquery_comparison.gif" medium="image">
			<media:title type="html">SQL/XML and XQuery comparison</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_web_services.gif" medium="image">
			<media:title type="html">Incoming SOAP message</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_web_service_example.gif" medium="image">
			<media:title type="html">XQuery and Web Services Example</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_sample_data.gif" medium="image">
			<media:title type="html">Sample XML Data</media:title>
		</media:content>

		<media:content url="http://www.stylusstudio.com/images/figures/sql_xml_xquery_webservice_example.gif" medium="image" />
	</item>
		<item>
		<title>Calling Oracle Text&#8217;s PL/SQL Procedures From PHP</title>
		<link>http://gudangberas.wordpress.com/2006/08/11/calling-oracle-texts-plsql-procedures-from-php/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/11/calling-oracle-texts-plsql-procedures-from-php/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 02:23:02 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/11/calling-oracle-texts-plsql-procedures-from-php/</guid>
		<description><![CDATA[A question was asked in the OTN PHP Forum  about how to call Oracle Text&#8217;s CTX_THES package  from PHP.   Oracle Text is described: Oracle Text uses standard SQL to index, search, and analyze text and documents stored in the Oracle database, in files, and on the web. Oracle Text can perform linguistic analysis on documents, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=20&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A question was asked in the <a href="http://forums.oracle.com/forums/thread.jspa?threadID=379991">OTN PHP Forum</a>  about how to call <a href="http://download-west.oracle.com/docs/cd/B19306_01/text.102/b14218/cthes.htm#CCREF1600">Oracle<br />
Text&#8217;s CTX_THES package</a>  from PHP.   Oracle Text is described:</p>
<p>Oracle Text uses standard SQL to index, search, and analyze text and documents stored in the Oracle database, in files, and on the web. Oracle Text can perform linguistic analysis on documents, as well as search text using a variety of strategies including keyword searching, context queries, Boolean operations, pattern matching, mixed thematic queries, HTML/XML section searching, and so on. It can render search results in various formats including unformatted text, HTML with term highlighting, and original document format. Oracle Text supports multiple languages and uses advanced relevance-ranking technology to improve search quality. Oracle Text also offers advanced features like classification, clustering, and support for information visualization metaphors.<br />
To make it simpler to see what to do, let&#8217;s set up an example package with a similar interface to CTX_THES.  This example ctx.sql just returns random data<span>:</span><br />
<span></span></p>
<pre><span>-- Package "SuppliedPkg" simulates Oracle Text's CTX_THES.
-- </span><span>It has a </span><span>procedure that returns a PL/SQL type.

create or replace package SuppliedPkg as
  type SuppliedRec is record (
      id   number,
      data varchar2(100)
  );
  type SuppliedTabType is table of SuppliedRec
       index by binary_integer;
  procedure SuppliedProc(p_p in out nocopy SuppliedTabType);
end SuppliedPkg;
/

create or replace package body SuppliedPkg as
  procedure SuppliedProc(p_p in out nocopy SuppliedTabType) is
  begin
    -- Create some random results
    p_p.delete;
    for i in 1..5 loop
      p_p(i).id   := i;
      p_p(i).data := 'Random: ' || i ||
               (1+ABS(MOD(dbms_random.random,100000)));
    end loop;
  end SuppliedProc;
end SuppliedPkg;
/
</span></pre>
<p>Run it in SQL*Plus like:<br />
<span></span></p>
<pre>sqlplus <a href="mailto:hr/hr@//localhost/XE">hr/hr@//localhost/XE</a> @ctx.sql</pre>
<p>This is the &#8220;fixed&#8221; part of the problem, representing the pre-supplied functionality.  It seems impossible to call SuppliedProc() and return its data to PHP.<br />
Since you can&#8217;t change SuppliedProc(), you can create a helper function in PL/SQL to convert the PL/SQL type SuppliedTabType to a pair of SQL types. Myproc.sql is:</p>
<pre>-- Create a wrapper procedure that calls the pre-supplied
-- SuppliedProc() and converts its output to SQL types.

create or replace type MyIdRec as varray(100) of number;
/
create or replace type MyDataRec as varray(100) of varchar2(100);
/

create or replace procedure MyProc
      (p_id IN OUT MyIdRec, p_data IN OUT MyDataRec)
as
  l_results SuppliedPkg.SuppliedTabType;
begin

-- get results from existing procedure
  SuppliedPkg.SuppliedProc(l_results);

-- copy to a type we can pass back to PHP
  p_id.delete;
  p_data.delete;
  for i in 1..l_results.count loop
    p_id.extend;
    p_id(i) := l_results(i).id;
    p_data.extend;
    p_data(i) := l_results(i).data;
  end loop;

end MyProc;
/</pre>
<p>Use SQL*Plus to run this script too.  Now you can call MyProc() in ctx.php:</p>
<pre>size(); $i++) {
  $id   = $res_id-&gt;getElem($i);
  $data = $res_data-&gt;getElem($i);
  echo "Id: $id, Data: $data";
}
?&gt;</pre>
<p>This allocates two collections and binds them as the parameters to MyProc().  After MyProc() has been called, the collection method getElem() is used to access each value returned.</p>
<p>The limitation of this example is that you have to set an upper bound on the MyIdRec and MyDataRec VARRAY sizes.  Simply replace both uses of VARRAY2(100) with TABLE to overcome this.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=20&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/11/calling-oracle-texts-plsql-procedures-from-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
		<item>
		<title>Excel Topics</title>
		<link>http://gudangberas.wordpress.com/2006/08/10/excel-topics/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/10/excel-topics/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 10:22:04 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[excel]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/10/excel-topics/</guid>
		<description><![CDATA[Excel is a spreadsheet and analysis program released by Microsoft. We&#8217;ve categorized Excel into the following topics: Cells Macros<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=19&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><b>Excel</b> is a spreadsheet and analysis program released by Microsoft. We&#8217;ve categorized Excel into the following topics:</p>
<table border="0" cellpadding="0" cellspacing="10" width="100%">
<tr valign="top">
<td width="40%"><a href="http://www.techonthenet.com/excel/cells/index.php">Cells</a></td>
<td width="60%"><a href="http://www.techonthenet.com/excel/macros/index.php">Macros</a></td>
</tr>
</table>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=19&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/10/excel-topics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
		<item>
		<title>Ajax Framework</title>
		<link>http://gudangberas.wordpress.com/2006/08/10/ajax-framework/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/10/ajax-framework/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 08:49:57 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/10/ajax-framework/</guid>
		<description><![CDATA[Overview The AJAX Framework is a cross browser framework that allows developers to quickly develop web pages that can call web services and server pages through javascript without having to submit the current page. Examples callPage example: function pageCallback(response){ alert(response); } var ajax = new AJAX(); ajax.callPage(&#8220;mypage.html&#8221;, pageCallback); serviceCall example: function serviceCallback(response){ alert(response); } var [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=18&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td>Overview</td>
</tr>
<tr>
<td valign="top">The AJAX Framework is a cross browser framework that allows developers to  			quickly develop web pages that can call web services and server pages through  			javascript without having to submit the current page.</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Examples</td>
</tr>
<tr>
<td><b>callPage example:</b></p>
<p><code> 			function pageCallback(response){ 			</code></p>
<blockquote><p>alert(response);</p></blockquote>
<p>}</p>
<p>var ajax = new AJAX();<br />
ajax.callPage(&#8220;mypage.html&#8221;, pageCallback);</td>
</tr>
<tr>
<td><b>serviceCall example:</b></p>
<p><code> 			function serviceCallback(response){ 			</code></p>
<blockquote><p>alert(response);</p></blockquote>
<p>}</p>
<p>var ajax = new AJAX();<br />
ajax.callService(&#8220;MyWebService.asmx&#8221;, &#8220;MyMethodToCall&#8221;, serviceCallback);</td>
</tr>
<tr>
<td><b>serviceCall with parameters example:</b></p>
<p><code> 			function serviceCallback(response){ 			</code></p>
<blockquote><p>alert(response);</p></blockquote>
<p>}</p>
<p>var ajax = new AJAX();<br />
/* paramters are added to the end of the callService method in key=value pairs. */<br />
ajax.callService(&#8220;MyWebService.asmx&#8221;, &#8220;MyMethodToCall&#8221;, serviceCallback, &#8220;myParameter1=hello&#8221;, &#8220;myParameter2=world&#8221;);</td>
</tr>
<tr>
<td><b>serviceCall with custom namespace example:</b></p>
<p><code> 			function serviceCallback(response){ 			</code></p>
<blockquote><p>alert(response);</p></blockquote>
<p>}</p>
<p>var ajax = new AJAX();<br />
/* set new namespace for use with web service. */<br />
ajax.setNameSpace(&#8220;http://mynamespaceuri/&#8221;);<br />
ajax.callService(&#8220;MyWebService.asmx&#8221;, &#8220;MyMethodToCall&#8221;, serviceCallback, &#8220;myParameter1=hello&#8221;, &#8220;myParameter2=world&#8221;);</td>
</tr>
<tr>
<td><b>error handling example:</b></p>
<p><code> 			/* by default the errors are alerted.  To suppress this you must redirect them. */<br />
function myErrorHandler(error){ 			</code></p>
<blockquote><p>alert(error);</p></blockquote>
<p>}</p>
<p>var ajax = new AJAX();<br />
ajax.onError = myErrorHandler;</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Download</td>
</tr>
<tr>
<td>Download the latest version at <a href="http://sourceforge.net/projects/glm-ajax/">http://sourceforge.net/projects/glm-ajax/</a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=18&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/10/ajax-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle: Database for Debian</title>
		<link>http://gudangberas.wordpress.com/2006/08/10/oracle-database-for-debian/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/10/oracle-database-for-debian/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 08:45:41 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/10/oracle-database-for-debian/</guid>
		<description><![CDATA[Debian Packages: libc6-dev binutils Installing Oracle on Debian has involved obtaining the Oracle tar file, setting up an Oracle user and some Oracle groups, and running the Oracle installation software. We include here a collection of information for installing Oracle 8 and Oracle 10g, with some pointers regarding Oracle 9i. The good news is that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=17&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><i>Debian Packages:</i> <a name="10244"></a><a name="10245"></a><a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=libc6-dev&amp;searchon=names&amp;subword=1&amp;version=all&amp;release=all" name="tex2html822" target="_parent"><span class="textbf">libc6-dev</span></a> <a name="10248"></a><a name="10249"></a><a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=binutils&amp;searchon=names&amp;subword=1&amp;version=all&amp;release=all" name="tex2html823" target="_parent"><span class="textbf">binutils</span></a></p>
<p>Installing Oracle on Debian has involved obtaining the Oracle tar file, setting up an Oracle user and some Oracle groups, and running the Oracle installation software.  We include here a collection of information for installing Oracle 8 and Oracle 10g, with some pointers regarding Oracle 9i. The good news is that Oracle now (as of March 2006) have an apt repository for the unstable (sid) distribution, and have provided the Oracle XE packaged for Debian. It is available from <a href="http://oss.oracle.com/debian/" name="tex2html818" target="_parent">http://oss.oracle.com/debian/</a>.</p>
<p>Additional information is also available from <a href="http://openacs.org/doc/openacs-4/oracle.html" name="tex2html819" target="_parent">http://openacs.org/doc/openacs-4/oracle.html</a>,  <a href="http://frits.homelinux.com/wordpress/?p=9" name="tex2html820" target="_parent">http://frits.homelinux.com/wordpress/?p=9</a>, and  <a href="http://www.davidpashley.com/articles/oracle-install.html" name="tex2html821" target="_parent">http://www.davidpashley.com/articles/oracle-install.html</a>.</p>
<p>To install Oracle XE you first need to tell wajig where to obtain the packages from:</p>
<table width="100%">
<tr bgcolor="#eeeeee">
<td width="100%">
<pre>$ wajig editsources
      -&gt; deb http://oss.oracle.com/debian unstable main non-free</pre>
</td>
</tr>
</table>
<p>Then install the <a name="10258"></a><a name="10259"></a><a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=libaio&amp;searchon=names&amp;subword=1&amp;version=all&amp;release=all" name="tex2html824" target="_parent"><span class="textbf">libaio</span></a> package&#8211;since version 10 of Oracle on GNU/Linux asynchronous IO has been the default &#8220;out of the box.&#8221;</p>
<table width="100%">
<tr bgcolor="#eeeeee">
<td width="100%">
<pre>$ wajig install libaio</pre>
</td>
</tr>
</table>
<p>Next, install the appropriate Oracle package. If you want just a client, then:</p>
<table width="100%">
<tr bgcolor="#eeeeee">
<td width="100%">
<pre>$ wajig install oracle-xe-client</pre>
</td>
</tr>
</table>
<p>To install the usual Oracle XE server:</p>
<table width="100%">
<tr bgcolor="#eeeeee">
<td width="100%">
<pre>$ wajig install oracle-xe</pre>
</td>
</tr>
</table>
<p>And to install a version of the server that supports needing multibyte character sets inside the database:</p>
<table width="100%">
<tr bgcolor="#eeeeee">
<td width="100%">
<pre>$ wajig install oracle-xe-universal</pre>
</td>
</tr>
</table>
<table width="100%">
<tr>
<td bgcolor="#246fff">&nbsp;</td>
</tr>
</table>
<p><!--Table of Child-Links--> <a name="CHILD_LINKS"></a><strong>Subsections</strong></p>
<ul>
<li><a href="http://linux.togaware.com/survivor/Oracle_8.html" name="tex2html12023">Oracle 8</a>
<ul>
<li><a href="http://linux.togaware.com/survivor/Obtaining_Distribution.html" name="tex2html12024">Obtaining the Distribution</a></li>
<li><a href="http://linux.togaware.com/survivor/Oracle_User.html" name="tex2html12025">Oracle User and Groups</a></li>
<li><a href="http://linux.togaware.com/survivor/Oracle_Installation.html" name="tex2html12026">Oracle Installation</a>
<ul>
<li><a href="http://linux.togaware.com/survivor/File_Locations.html" name="tex2html12027">File Locations</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://linux.togaware.com/survivor/Oracle_10g.html" name="tex2html12028">Oracle 10g Release 2</a>
<ul>
<li><a href="http://linux.togaware.com/survivor/Preliminary.html" name="tex2html12029">Preliminary</a></li>
<li><a href="http://linux.togaware.com/survivor/Getting_Oracle.html" name="tex2html12030">Getting Oracle 10g</a></li>
<li><a href="http://linux.togaware.com/survivor/System_Parameters.html" name="tex2html12031">System Parameters</a></li>
<li><a href="http://linux.togaware.com/survivor/Oracle_Accounts.html" name="tex2html12032">Oracle Accounts</a></li>
<li><a href="http://linux.togaware.com/survivor/Kernel_Parameters.html" name="tex2html12033">Kernel Parameters</a></li>
<li><a href="http://linux.togaware.com/survivor/Oracle_User0.html" name="tex2html12034">Oracle User Setup</a></li>
<li><a href="http://linux.togaware.com/survivor/Installing_Oracle.html" name="tex2html12035">Installing Oracle 10g</a></li>
<li><a href="http://linux.togaware.com/survivor/Starting_Stopping.html" name="tex2html12036">Starting and Stopping Oracle 10g</a></li>
<li><a href="http://linux.togaware.com/survivor/Using_Oracle.html" name="tex2html12037">Using Oracle 10g</a></li>
<li><a href="http://linux.togaware.com/survivor/Importing_data.html" name="tex2html12038">Importing data from Comma Seperated Value (CSV) files</a></li>
<li><a href="http://linux.togaware.com/survivor/XDB.html" name="tex2html12039">XDB</a></li>
<li><a href="http://linux.togaware.com/survivor/Troubleshooting000000000.html" name="tex2html12040">Troubleshooting</a>
<ul>
<li><a href="http://linux.togaware.com/survivor/Missing_Packages.html" name="tex2html12041">Missing Packages</a></li>
<li><a href="http://linux.togaware.com/survivor/X_DISPLAY.html" name="tex2html12042">X DISPLAY</a></li>
<li><a href="http://linux.togaware.com/survivor/runInstaller_as.html" name="tex2html12043">runInstaller as oracle</a></li>
<li><a href="http://linux.togaware.com/survivor/Starting_iSQLPlus.html" name="tex2html12044">Starting iSQLPlus</a></li>
<li><a href="http://linux.togaware.com/survivor/NLS_DATE.html" name="tex2html12045">NLS DATE FORMAT</a></li>
<li><a href="http://linux.togaware.com/survivor/Enabling_Swap.html" name="tex2html12046">Enabling Swap</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=17&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/10/oracle-database-for-debian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
		<item>
		<title>MochiKit</title>
		<link>http://gudangberas.wordpress.com/2006/08/10/mochikit/</link>
		<comments>http://gudangberas.wordpress.com/2006/08/10/mochikit/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 08:41:11 +0000</pubDate>
		<dc:creator>gudangberas</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">https://gudangberas.wordpress.com/2006/08/10/mochikit/</guid>
		<description><![CDATA[MochiKit is a highly documented and well tested, suite of JavaScript libraries that will help you get shit done, fast. We took all the good ideas we could find from our Python, Objective-C, etc. experience and adapted it to the crazy world of JavaScript. Reliable MochiKit has HUNDREDS of tests. We build real applications with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=16&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>MochiKit is a <a href="http://www.mochikit.com/doc/html/MochiKit/index.html">highly documented</a> and <a href="http://www.mochikit.com/tests/index.html">well tested</a>, suite of JavaScript libraries that will help you get shit done, fast. We took all the good ideas we could find from our Python, Objective-C, etc. experience and adapted it to the crazy world of JavaScript.</p>
<h2>Reliable</h2>
<p>MochiKit has HUNDREDS of tests.  We build <a href="http://mochibot.com/" title="MochiBot">real applications</a> with this thing. So even though development can move fast, we make sure to get tests written. This also makes platform compatibility issues much easier to detect and resolve than the &#8220;guess and check&#8221; style of quality assurance seen in some of the other libraries out there. It&#8217;s not broken.</p>
<h2>Documented</h2>
<p>You&#8217;re unlikely to find any JavaScript code with better documentation than MochiKit. We make a point to maintain <a href="http://www.mochikit.com/doc/html/MochiKit/index.html">100% documentation coverage</a> for all of MochiKit at all times. You don&#8217;t have to fumble around reading our source code or leafing through examples to find out how something works.</p>
<h2>Evolutionary</h2>
<p>MochiKit can adapt to anything you throw at it. It makes no assumptions about how your code needs to act, and it has hooks (by way of the the <a href="http://www.mochikit.com/doc/html/MochiKit/Base.html#adapter-registries">adapter registries</a>)                                         that makes sure that you can define your own                                         <a href="http://www.mochikit.com/doc/html/MochiKit/Base.html#comparison">comparisons</a>,                                         <a href="http://www.mochikit.com/doc/html/MochiKit/Base.html#programmer-representation">programmer representations</a>,                                         <a href="http://www.mochikit.com/doc/html/MochiKit/Iter.html#iteration-for-javascript">iterators</a>,                                         or <a href="http://www.mochikit.com/doc/html/MochiKit/DOM.html#dom-coercion-rules">DOM node coercion</a>                                         for any object in any way you wish.  We&#8217;ll gladly serve you all the Kool-Aid you want,                                         but we&#8217;re not going to make you drink any.</p>
<h2>Plays well with others</h2>
<p>Although MochiKit can be, and often is, used as a one stop shop for JavaScript goodness; it is very highly interoperable. MochiKit does no <tt>Object.prototype</tt> hacking, and inserts just three                                         symbols (the <tt>MochiKit</tt> namespace, plus the <tt>compare</tt> and <tt>reduce</tt> functions                                         to work around <a href="http://blogs.msdn.com/ericlippert/archive/2005/05/04/414684.aspx">JScript bugs</a>) into the global namespace. Unless, of course, you ask it to bring in more symbols for convenience.</p>
<p>As far as server-side goes, MochiKit is totally agnostic. However, feel free to include MochiKit as part of your AJAX arsenal &#8211; <a href="http://turbogears.org/">TurboGears</a> does out of the box!</p>
<h2>All your JavaScript are belong to…</h2>
<p>The new packaging systems that have sprouted up recently are extremely cool, and WILL be revolutionizing JavaScript development. <a href="http://openjsan.org/" title="JavaScript Archive Network">JSAN</a> and <a href="http://dojotoolkit.org/" title="Dojo Toolkit">Dojo Toolkit</a> are fully supported by and interoperable with MochiKit! Don&#8217;t worry though, MochiKit still works fine on its own if you aren&#8217;t interested in those new fangled packaging systems.</p>
<h2>Free as in…</h2>
<p>You won&#8217;t see any political agenda nonsense here. MochiKit is available to you under the extremely liberal <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>, or the                                         written-by-a-very-smart-lawyer <a href="http://www.opensource.org/licenses/afl-2.1.php">Academic Free License, v2.1</a>. It&#8217;s your choice! We don&#8217;t want to &#8220;infect&#8221; YOUR software with our ideals, we just want to make every developers&#8217; life suck just a little bit less. MochiKit is free as in we don&#8217;t care what you do with it. With the choice of these two licenses, you can put MochiKit anywhere. We certainly won&#8217;t refuse if you offer free beer, though.</p>
<h2>Compatibility</h2>
<p>Our current test platforms include all of the modern and popular browsers: Safari 2.0.2, Firefox 1.0.7, Firefox 1.5b2, Internet Explorer 6, and Opera 8.5. Other JavaScript platforms should work if they&#8217;re standards compliant (<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> and the <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ecma-script-binding.html">W3C DOM ECMAScript binding</a>, primarily).</p>
<p>Yes, we&#8217;re aware that a lot of people use other browsers, but the above list matches an astronomically high percentage of the intended audience of our <a href="http://mochibot.com/">flagship application</a>.  Please let us know if you encounter any problems elsewhere, especially if you can contribute a fix.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gudangberas.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gudangberas.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gudangberas.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gudangberas.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gudangberas.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gudangberas.wordpress.com&amp;blog=166807&amp;post=16&amp;subd=gudangberas&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gudangberas.wordpress.com/2006/08/10/mochikit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c3d5e6434cd6e20ccef6c12ea4012701?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gudangberas</media:title>
		</media:content>
	</item>
	</channel>
</rss>
