On 21.01.2006, at 19:01, Igor Tandetnik wrote:
Weissmann Markus <[EMAIL PROTECTED]> wrote:
could someone please elaborate on this one?
sqlite> create table t (a int primary key, b int, check(0<b<1000));
sqlite> insert into t(b) values(100000000);
does not complain, so what checks exactly can we do now?
check(0<b<1000) does not do what you think it does. An expression
0<b<1000 is evaluated as (0<b)<1000. That is, first (0 < b) is
evaluated and returns 0 or 1 depending on whether the condition is
false or true. Next, (x < 1000) is evaluated where x is 0 or 1 (the
result of the first subexpression). Obviously, this latter
condition is always true.
You want check(0<b and b<1000)
oh, well - thanks for this hint! Nevertheless sqlite 3.3.1 (still)
does not complain:
SQLite version 3.1.3
sqlite> create table t (a integer primary key, b integer, check(b > 0));
sqlite> insert into t(b) values(-19);
sqlite> select * from t;
1|-19
-Markus
---
Markus W. Weissmann
http://www.mweissmann.de/
http://www.opendarwin.org/~mww/