Hi,
I have written the following trigger with ideas from stackoverflow:
(OSX 10.6.8, SQLite 3.6.12)
This is for a book library. If i delete a bookexemplar from the library,
this should not be possible if this bookexemplar is on loan, which means
ausleihen.rueckgabe IS NULL. Otherwise every information on loans should
be deleted, too.
CREATE TRIGGER buchexemplare_delete
AFTER DELETE ON buchexemplare
FOR EACH ROW
BEGIN
SELECT CASE
WHEN EXISTS (SELECT beid FROM ausleihen
WHERE (ausleihen.beid = OLD.beid) AND\
(ausleihen.rueckgabe IS NULL))
THEN RAISE(ROLLBACK, 'Es sind noch Buchexemplare\
ausgeliehen')
END;
DELETE FROM ausleihen
WHERE ausleihen.beid = OLD.beid;
END;
this trigger does work but i think it is not in accordance with the
syntax diagram of TRIGGER on
http://sqlite.com/lang_createtrigger.html
So where can i find the exact actual syntax for triggers and maybe some
examples?
Thank you for any help
Wolfgang
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users