Re: CASE Statement

From: Serge Rielau <srielau_at_ca.ibm.com>
Date: Wed, 25 Jun 2008 07:45:54 -0400
Message-ID: <6cepfhF3fu2v6U1@mid.individual.net>


Nit:
SQL knows two (aside from searched vs. simple) different forms of CASE constructs:
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):
CASE
  WHEN a > b THEN
   INSERT INTO T VALUES (1);
  WHEN b < a THEN
   INSERT INTO T VALUES (2);
END CASE; Expression:
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.

Cheers
Serge

-- 
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Received on Wed Jun 25 2008 - 06:45:54 CDT

Original text of this message