3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # Use of row values in CASE statements.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set ::testprefix rowvalue8
19 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
20 INSERT INTO t1(a,b,c,d) VALUES
27 SELECT a, CASE (b,c) WHEN (1,2) THEN 'aleph'
29 WHEN (3,4) THEN 'gimel'
34 } {1 aleph | 2 bet | 3 aleph | 4 bet | 5 gimel | 6 - |}
36 SELECT a, CASE (b,c,d) WHEN (1,2,3) THEN 'aleph'
37 WHEN (2,3,4) THEN 'bet'
38 WHEN (3,4,6) THEN 'gimel'
43 } {1 aleph | 2 bet | 3 - | 4 - | 5 gimel | 6 - |}
46 CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
47 INSERT INTO t2(x,y) VALUES(1,6),(2,5),(3,4),(4,3),(5,2),(6,1);
48 SELECT x, CASE (SELECT b,c FROM t1 WHERE a=y)
49 WHEN (1,2) THEN 'aleph'
51 WHEN (3,4) THEN 'gimel'
56 } {1 - | 2 gimel | 3 bet | 4 aleph | 5 bet | 6 aleph |}