> But how we can resolve this situation without > manual types casting?
SQLite version 3.6.23.1 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t (n integer); sqlite> create trigger tr before insert on t begin select raise(fail, 'Value must be positive') where typeof(new.n) != 'integer' or new.n < 0; end; sqlite> insert into t values (5); sqlite> insert into t values (-5); Error: Value must be positive sqlite> insert into t values ('-5'); Error: Value must be positive sqlite> insert into t values ('5'); sqlite> insert into t values ('q'); Error: Value must be positive sqlite> select n, typeof(n) from t; 5|integer 5|integer sqlite> Pavel On Thu, Apr 29, 2010 at 9:25 AM, Alexey Pechnikov <pechni...@mobigroup.ru> wrote: > Yes, I did understand. But how we can resolve this situation without > manual types casting? Now datatyping working correct only with manual > casting but it's hard to use: > > sqlite> CREATE TABLE T2 (N INTEGER CHECK(TYPEOF(N) = 'integer')); > sqlite> INSERT INTO T2 VALUES('5'); > Error: constraint failed > sqlite> INSERT INTO T2 VALUES(CAST('5' AS INTEGER)); > > 2010/4/29 Igor Tandetnik <itandet...@mvps.org>: >> I wasn't proposing this as a solution. It was an experiment, an attempt to >> illustrate what was going on. I though I made it clear - I even show that >> negative values slip through this check ('q' would pass the original check, >> too). I can only assume you haven't actually read my message before jumping >> in to respond. > > -- > Best regards, Alexey Pechnikov. > http://pechnikov.tel/ > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users