Outer Joins
PostgreSQL supports the ANSI SQL 92 syntax, so outer joins for PostgreSQL should be written in the FROM clause. See the examples on constructing outer joins in the section “Outer Join Constructs In the FROM Clause (ANSI-Compliant)” in the DB Interface Module User’s Guide.
The following example shows an outer join program for PostgreSQL. You can assume that myDbase is a valid instance of RWDBDatabase.
Example 3 – An outer join for PostgreSQL using ANSI-compliant syntax
RWDBTable employee = myDbase.table("emp");
RWDBTable depart = myDbase.table("dept");
RWDBTable locate = myDbase.table("loc");
 
RWDBSelector selector = myDbase.selector();
selector << employee["empnum"] << employee["ename"]
<< employee["deptno"] << depart["deptno"]
<< depart["dname"] << depart["locno"]
<< locate["locno"] << locate["lname"];
 
// Define and declare join1 as a right outer join
// between the tables emp and dept.
RWDBJoinExpr join1 = rwdbRightOuter(employee, depart);
 
// Attach the join criterion to join1 using
// the on() method. This criterion joins the two tables
// emp and dept by their deptno columns.
join1.on(employee["deptno"] == depart["deptno"]);
 
// Define and declare join2 as a left outer join
// between the table loc and join1, forming a nested join.
// Note that the nested join must be specified as second
// parameter and not first.
RWDBJoinExpr join2 = rwdbLeftOuter(locate, join1);
 
// Attach the join criterion to the join2 using
// the on() method. This criterion joins the two tables
// dept and loc by their locno columns.
join2.on(depart["locno"] == locate["locno"]);
 
// Attach join2 explicitly to the selector FROM clause
// using the from() method.
selector.from(join2);