Did you consider using foreign keys (assuming you have the latest version of SQLite)?
Pavel On Mon, Mar 1, 2010 at 10:47 AM, Артемий Васюков <[email protected]> wrote: > Hello! > > I need to check if parent of group is exist or not. > Parent stored in "parent" column and may be NULL or will be existing > "idgroup" column value. > It does not works because subqueries prohibited in CHECK constraints. > > My table showed below (incorrect constraint commented). > > ---------------------------------------------------------------------------------------------------------------------- > CREATE TABLE GROUPS ( > idgroup INTEGER PRIMARY KEY, > groupname VARCHAR(255) NOT NULL UNIQUE, > parent INTEGER NULL, > description TEXT NULL > -- CONSTRAINT PARENTCHECK > -- CHECK ( parent == NULL OR EXISTS ( SELECT idgroup WHERE idgroup > = parent ) ) > ); > ---------------------------------------------------------------------------------------------------------------------- > > Somebody knows how to solve this problem? > > Thanks, > Artem. > _______________________________________________ > 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

