Outer joins

The original OUTER join syntax of Informix® is different from the IBM® DB2® outer join syntax:

See the IBM DB2 SQL reference for a complete description of the syntax.

Solution

For better SQL portability, you should use the ANSI outer join syntax instead of the old Informix OUTER syntax.

The IBM DB2 interface can convert most Informix OUTER specifications to IBM DB2 outer joins.

Prerequisites:

  1. In the FROM clause, the main table must be the first item and the outer tables must figure from left to right in the order of outer levels. Example which does not work: "FROM OUTER(tab2), tab1".
  2. The outer join in the WHERE clause must use the table name as prefix. Example: "WHERE tab1.col1 = tab2.col2".

Restrictions:

  1. Additional conditions on outer table columns cannot be detected and therefore are not supported:

    Example: "... FROM tab1, OUTER(tab2) WHERE tab1.col1 = tab2.col2 AND tab2.colx > 10"

  2. Statements composed by 2 or more SELECT instructions using OUTERs are not supported.

    Example: "SELECT ... UNION SELECT" or "SELECT ... WHERE col IN (SELECT...)"

Note:
  • Table aliases are detected in OUTER expressions.

    OUTER example with table alias: "OUTER( tab1 alias1)"

  • In the outer join, outer table.column-name can be placed on both right or left sides of the equal sign.

    OUTER join example with table on the left: "WHERE outertab.col1 = maintab.col2 "

  • Table names detection is not case-sensitive.

    Example: "SELECT ... FROM tab1, TAB2 WHERE tab1.col1 = tab2.col2"

  • Temporary tables are supported in OUTER specifications.