Tareq Khan <tk...@quantinity.com> wrote: > I have looked through the list with regards to my issue and there are > several entries that say that the following is correct for a BEFORE INSERT > trigger: > > > > CREATE TRIGGER AlbumSectionInsertTrigger > BEFORE INSERT > ON AlbumSection > FOR EACH ROW > > BEGIN > SELECT CASE > WHEN ((NEW.AlbumID IS NOT NULL) AND ((SELECT Album.AlbumID FROM > Album WHERE Album.AlbumID = NEW.AlbumID) IS NULL)) > THEN RAISE(ABORT, 'FK VIOLATION INSERT AlbumID ON AlbumSection') > END; > END; > > But when I try to compile this I get an error: > > SQL Error: near " > ": syntax error
Are you sure the error you get is about this statement, and not some other one? This statement compiles for me just fine. Besides, it doesn't contain " character anywhere. > But then how do I perform multiple RI checks? Try this: BEGIN select RAISE(ABORT, 'FK VIOLATION INSERT AlbumID ON AlbumSection') where NEW.AlbumID IS NOT NULL and NEW.AlbumID not in (select AlbumID from Album); select RAISE(ABORT, 'Another problem') where another_condition; END; Are you aware that recent SQLite versions provide native support and enforcement of foreign keys? -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users