|Oracle9i Application Developer's Guide - Fundamentals
Release 2 (9.2)
Part Number A96590-01
Often, a programming project requires adapting existing code rather than writing new code. When that code comes from some other database platform, it is important to understand the Oracle features that are designed to make porting easy.
Topics include the following:
When porting queries from other database systems to Oracle, you might have needed in the past to translate ANSI join notation into Oracle's comma notation.
You can now code Oracle queries using ANSI-compliant notation for joins. For example:
SELECT * FROM a NATURAL JOIN b; SELECT * FROM a JOIN b USING (c1); SELECT * FROM a JOIN b USING (c1) WHERE c2 > 100; SELECT * FROM a NATURAL JOIN b INNER JOIN c;
The standard notation makes the relations between the tables explicit, and saves you from coding equality tests for join conditions in the
WHERE clause. Support for full outer joins also eliminates the need for complex workarounds to do those queries.
Because different vendors support varying amounts of standard join syntax, and some vendors introduce their own syntax extensions, you might still need to rewrite some join queries.
See Oracle9i SQL Reference for full syntax of the
SELECT statement and the support for join notation.
Yes. Oracle provides a free product called the Oracle Migration Workbench that can convert a schema (including data, triggers, and stored procedures) from other database products to Oracle8 and Oracle8i. Although the product itself runs on Windows, it can transfer data from databases on other operating systems, to Oracle databases running on any operating systems.
By using this product, you can avoid having to write your own applications to convert your legacy data when switching to Oracle8i. Related technology lets you convert certain kinds of source code, for example to migrate Visual Basic code to Java.
At the time of this publication, migration is supported from the following databases:
For the current set of supported databases, see the Web site:
When you want to choose from many different conditions within a query, you can use:
SELECT CASE WHEN day IN ('Monday','Tuesday','Wednesday','Thursday','Friday') THEN 'weekday' WHEN day in ('Saturday','Sunday') THEN 'weekend' ELSE 'unknown day' END FROM DUAL;
This technique helps performance when you can replace a call to a PL/SQL function with a test done directly in SQL.
Oracle8i supports the SQL-92 notation for searched case, simple case,
SELECT DECODE (day, 'Monday', 'weekday', 'Tuesday', 'weekday', 'Wednesday', 'weekday', 'Thursday', 'weekday', 'Friday', 'weekday', 'Saturday', 'weekend', 'Sunday', 'weekend, 'unknown day') INTO day_category FROM DUAL;
This construct lets you test a variable against a number of different alternatives, and return a different value in each case. The final value is used when none of the alternatives is matched.
CASE technique is more portable, and is preferable for new code.
Oracle9i does support scalar subqueries.