Hi Thanks for the reply. Yes I am aware of that... I have just updated to the latest version. However I would be grateful if someone could tell me what was wrong with the trigger I was trying to create. Do you think it is just a version issue?
Many thanks Tareq -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik Sent: 10 June 2010 13:13 To: sqlite-users@sqlite.org Subject: Re: [sqlite] BEFORE INSERT TRIGGER 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 __________ Information from ESET Smart Security, version of virus signature database 5186 (20100610) __________ The message was checked by ESET Smart Security. http://www.eset.com __________ Information from ESET Smart Security, version of virus signature database 5186 (20100610) __________ The message was checked by ESET Smart Security. http://www.eset.com _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users