Re: CASE Statement
Date: Wed, 25 Jun 2008 11:57:58 -0700 (PDT)
On Jun 25, 7:45 am, Serge Rielau <srie..._at_ca.ibm.com> wrote:
> SQL knows two (aside from searched vs. simple) different forms of CASE
> Statement and expression
> The CASE STATEMENT is a flavor of IF THEN ELSE procedural logic.
> I.e. it belongs into the world of SQL/PSM (or PL/SQL in the case of Oracle).
> The CASE EXPRESSION is a functional construct and belongs into the world
> of SQL queries.
> Statement (in SQL/PSM notation):
> WHEN a > b THEN
> INSERT INTO T VALUES (1);
> WHEN b < a THEN
> INSERT INTO T VALUES (2);
> END CASE;
> INSERT INTO T VALUES (CASE WHEN a > b THEN 1 WHEN b < a THEN 2 END);
> So it pays to be precise on the wording here to clarify what's being
> looked for.
> Serge Rielau
> DB2 Solutions Development
> IBM Toronto Lab
Serge has a point. The Oracle 10gR2 SQL manual does refer to the case statement within SQL as a case expression:
CASE expressions let you use IF ... THEN ... ELSE logic in SQL statements without having to invoke procedures. <<
Proper terminology is important.
HTH -- Mark D Powell -- Received on Wed Jun 25 2008 - 13:57:58 CDT