In a message dated 00-03-17 12:10:18 EST, you write:
I was reading in the archives and someone mentioned that outer joins can be
negated. When does that happen?
It depends on how your database processes outer joins, but a condition on the “outer” portion of the join will effectively negate the “outer” part of the join. For example, assume table A and table B are joined in an outer fashion, with table B being the child table (with possible missing rows). The following SQL will be okay:
select stuff
from A, B
where A.ID = B.ID(+)
The (+) is Oracle syntax. Now, if you try to also say that some field in B (say B.date1) has a condition, then you have a problem:
select stuff
from A, B
where A.ID = B.ID(+)
and B.date1 = sysdate
As soon as the SQL is parsed, the outer join becomes negated since the second condition on table B is not part of the outer expression. You would need something like:
select stuff
from A, B
where A.ID = B.ID(+)
and B.date1(+) = sysdate
Again, Oracle syntax. As luck would have it, there is a paper on our web site that details some ideas / tricks for working with outer joins. You can find it at
http://www.islink.com/bobjtech.htm
Look for the article on outer joins. It specifically mentions Oracle, but can be adapted for use with other databases.
I have a report showing Orders and Invoices. I want it to return all order numbers in a particular date range whether or not an invoice has been generated against it. Is there another way to do this?
As long as you don’t have a condition on invoice information, you should be fine. Your condition on Orders within a date range should be okay, since the Orders table is the driving table. It’s the Invoices table that may have missing data.
Regards,
Dave Rathbun
Integra Solutions
www.islink.com
Listserv Archives (BOB member since 2002-06-25)