Hi
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
Also what I want to do is to do multiple RI checks on a table that has many
foreign keys... I thought the SELECT CASE would allow me to do this with
multiple WHEN... THEN... is this the correct approach?
If I use this syntax it works:
CREATE TRIGGER AlbumSectionInsertTrigger
BEFORE INSERT
ON AlbumSection
WHEN ((NEW.AlbumID IS NOT NULL) AND ((SELECT Album.AlbumID FROM Album
WHERE Album.AlbumID = NEW.AlbumID) IS NULL))
BEGIN
SELECT RAISE(ABORT, 'FK VIOLATION INSERT AlbumID ON AlbumSection');
END;
But then how do I perform multiple RI checks?
I would be very grateful for any help...
Many thanks
Tareq
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users