Dear list,

Is there a way to make SQLite accept this kind of constraint:

CREATE TABLE tab (
   id INTEGER NOT NULL,
   data INTEGER,
   CHECK(data = 0 or not exists (select 1 from tab where id = data)));

This toy exemple doesn't mean much as it is and the actual situation is 
a bit more involved.  Anyway, the crux of it is that the table name 
doesn't yet exist when the parser looks at the constraint, hence SQLite 
issues a "no such table: tab" error.

The docs say that a check table constraint can be any expression but 
this is clearly not the complete picture.

I tend to think that this statement should be accepted, but I'm in no 
way an expert in ISO SQL.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to