Re: Query with NULL

From: joel garry <>
Date: Wed, 30 Dec 2009 09:17:12 -0800 (PST)
Message-ID: <>

On Dec 30, 7:36 am, Mark D Powell <> wrote:

> While one query could be written to handle this set of requirements, I
> would consider to make the correct desired result clear for future
> maintenance programmers just coding a simple SQL statement for each
> condition within a IF structure within the program.  That way, based
> on which variables have values the correct desired SQL statement is
> submitted.
> I think taking the simple approach would likely greatly reduce the
> chance the CBO chooses anything but the optimal plan for the submitted
> query and again the simplier SQL will be unlikely to confuse any
> future maintenance programmer as to what result is desired.

I'd go for a CASE over IF for future maintenance, if it is a tossup. Had one of those yesterday, was so glad it was CASE - took 5 minutes, most of which was source control/comments, would have needed much more work if IF's. The issue is often that over time, the IF's get more complicated - people can't resist nesting and ELSE. This usually arises from changing business rules to account for all the situations not thought of (or admitted) originally. I know, you'd think there would be no difference since they can be logically equivalent... but programmer behavior removes the equivalency.


-- is bogus.
Received on Wed Dec 30 2009 - 11:17:12 CST

Original text of this message