If you want only positive values:
sqlite> create table t3(n integer check(abs(round(n)) = n));
sqlite> insert into t3 values('-5');
Error: constraint failed
Michael D. Black
Senior Scientist
Northrop Grumman Mission Systems
________________________________
From: [email protected] on behalf of Alexey Pechnikov
Sent: Thu 4/29/2010 9:07 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] CHECK constraints and type affinity
This is just for fun, isn't it? It'is not more simple then cast(... as
...) and has performance problem and produce big and dirty database
schema.
2010/4/29 Pavel Ivanov <[email protected]>:
>> But how we can resolve this situation without
>> manual types casting?
>
> 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;
--
Best regards, Alexey Pechnikov.
http://pechnikov.tel/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users