Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Modifications to documentation for CASE expressions. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6c47d70dc09d5c97c70b38c60e9c0ff6 |
User & Date: | dan 2010-08-24 13:11:33.000 |
Context
2010-08-26
| ||
19:07 | Changes to CAST expression documentation to make for more testable statements. (check-in: 6c20f79cbc user: dan tags: trunk) | |
2010-08-24
| ||
13:11 | Modifications to documentation for CASE expressions. (check-in: 6c47d70dc0 user: dan tags: trunk) | |
2010-08-23
| ||
22:51 | Preparation for the 3.7.2 release. (check-in: 7bf266483d user: drh tags: trunk) | |
Changes
Changes to pages/lang.in.
︙ | ︙ | |||
1453 1454 1455 1456 1457 1458 1459 | that with BETWEEN, the <i>x</i> expression is only evaluated once.)^ ^The precedence of the BETWEEN operator is the same as the precedence as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right. <tcl>hd_fragment case {CASE expression}</tcl> <h3>The CASE expression</h3> <p>A CASE expression serves a role similar to IF-THEN-ELSE in other | | < < < < | | > | > > > > > > | > | | | > > > > > > > | | | > > > > | > | > | | < < < < < < < < < | 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 | that with BETWEEN, the <i>x</i> expression is only evaluated once.)^ ^The precedence of the BETWEEN operator is the same as the precedence as operators <b>==</b> and <b>!=</b> and <b>LIKE</b> and groups left to right. <tcl>hd_fragment case {CASE expression}</tcl> <h3>The CASE expression</h3> <p>A CASE expression serves a role similar to IF-THEN-ELSE in other programming languages. <p>The optional expression that occurs in between the CASE keyword and the first WHEN keyword is called the "base" expression. ^There are two basic forms of the CASE expression: those with a base expression and those without. <p>^In a CASE without a base expression, each WHEN expression is evaluated and the result treated as a boolean, starting with the leftmost and continuing to the right. ^The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression that evaluates to true. ^Or, if none of the WHEN expressions evaluate to true, the result of evaluating the ELSE expression, if any. ^If there is no ELSE expression and none of the WHEN expressions are true, then the overall result is NULL. <p>^A NULL result is considered untrue when evaluating WHEN terms. <p>^In a CASE with a base expression, the base expression is evaluated just once and the result is compared against the evaluation of each WHEN expression from left to right. ^The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression for which the comparison is true. ^Or, if none of the WHEN expressions evaluate to a value equal to the base expression, the result of evaluating the ELSE expression, if any. ^If there is no ELSE expression and none of the WHEN expressions produce a result equal to the base expression, the overall result is NULL. <p>^When comparing a base expression against a WHEN expression, the same collating sequence, affinity, and NULL-handling rules apply as if the base expression and WHEN expression are respectively the left- and right-hand operands of an <big><b>=</b></big> operator.</p> ^If the base expression is NULL then the result of the CASE is always the result of evaluating the ELSE expression if it exists, or NULL if it does not. <p>^Both forms of the CASE expression use lazy, or short-circuit, evaluation. <p>^(The only difference between the following two CASE expressions is that the <i>x</i> expression is evaluated exactly once in the first example but might be evaluated multiple times in the second: <ul><pre> <li>CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END <li>CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END </pre></ul>)^ <tcl>hd_fragment in_op {IN operator} {NOT IN operator}</tcl> <h3>The IN and NOT IN operators</h3> <p>^The IN and NOT IN operators take a single scalar operand on the left and a vector operand on the right formed by an explicit list of zero or more scalars or by a single subquery. |
︙ | ︙ |