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

Reply via email to