05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 1 ■ DEVELOPING SUCCESSFUL ORACLE APPLICATIONS 35<br />

for different vendors method <strong>and</strong> use stored procedures heavily. This apparently seems to<br />

increase the amount of time it would take to implement on a different database. However, you<br />

will find it is actually easier to implement on multiple databases with this approach. Instead of<br />

having to find the perfect SQL that works on all databases (perhaps better on some than on<br />

others), you implement the SQL that works best on that database. You can do this outside of<br />

the application itself, giving you more flexibility in tuning the application. You can fix a poorly<br />

performing query in the database itself, <strong>and</strong> deploy that fix immediately, without having to<br />

patch the application. Additionally, you can take advantage of vendor extensions to SQL using<br />

this method freely. For example, <strong>Oracle</strong> supports hierarchical queries via the CONNECT BY operation<br />

in its SQL. This unique feature is great for resolving recursive queries. In <strong>Oracle</strong>, you are<br />

free to use this extension to SQL since it is “outside” of the application (i.e., hidden in the database).<br />

In other databases, you would use a temporary table <strong>and</strong> procedural code in a stored<br />

procedure to achieve the same results, perhaps. You paid for these features, so you might as<br />

well use them.<br />

This technique of developing a specialized layer of code for the database on which you<br />

will deploy is the same as that used by developers who implement multiplatform code. <strong>Oracle</strong><br />

Corporation, for example, uses these techniques in the development of its own database.<br />

There is a large amount of code (but a small percentage of the database code overall), called<br />

operating system–dependent (OSD) code, that is implemented specifically for each platform.<br />

Using this layer of abstraction, <strong>Oracle</strong> is able to make use of many native OS features for performance<br />

<strong>and</strong> integration, without having to rewrite the large majority of the database itself.<br />

The fact that <strong>Oracle</strong> can run as a multithreaded application on Windows <strong>and</strong> a multiprocess<br />

application on UNIX attests to this feature. The mechanisms for interprocess communication<br />

are abstracted to such a level that they can be reimplemented on an OS-by-OS basis, allowing<br />

for radically different implementations that perform as well as an application written directly,<br />

<strong>and</strong> specifically, for that platform.<br />

Another argument for this approach is that finding a single developer (let alone a team of<br />

developers) who is savvy enough to underst<strong>and</strong> the nuances of the differences between <strong>Oracle</strong>,<br />

SQL Server, <strong>and</strong> DB2 (let’s limit the discussion to three databases in this case) is virtually<br />

impossible. I’ve worked mostly with <strong>Oracle</strong> for the last 11 years (mostly, not exclusively). I<br />

learn something new about <strong>Oracle</strong> every single day I use it. To suggest that I could be expert in<br />

three databases simultaneously <strong>and</strong> underst<strong>and</strong> what the differences between all three are<br />

<strong>and</strong> how those differences will affect the “generic code” layer I would have to build is highly<br />

questionable. I doubt I would be able to do that accurately or efficiently. Also consider the fact<br />

that we are talking about individuals here—how many developers actually fully underst<strong>and</strong> or<br />

use the database they currently have, let alone three of them? Seeking to find the unique individual<br />

who can develop bulletproof, scalable, database-independent routines is a Holy Grail<br />

quest. Building a team of developers that can do this is impossible. Finding an <strong>Oracle</strong> expert, a<br />

DB2 expert, <strong>and</strong> a SQL Server expert, <strong>and</strong> telling them “We need a transaction to do X, Y <strong>and</strong><br />

Z”—that’s relatively easy. They are told, “Here are your inputs, these are the outputs we need,<br />

<strong>and</strong> this is what this business process entails,” <strong>and</strong> from there it is relatively simple to produce<br />

transactional APIs (stored procedures) that fit the bill. Each will be implemented in the best<br />

manner for that particular database, according to that database’s unique set of capabilities.<br />

These developers are free to use the full power (or lack thereof, as the case may be) of the<br />

underlying database platform.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!