Igor: Your answer includes two points that I consider very illustrative, at least for my.
Although I am relatively new in this forum, I believe that your interventions always mean interesting. Greetings. A. J. Millan ----- Original Message ----- From: "Igor Tandetnik" <[EMAIL PROTECTED]> To: "SQLite" <sqlite-users@sqlite.org> Sent: Tuesday, November 14, 2006 1:01 AM Subject: [sqlite] Re: Trouble with Trigger > > You cannot put a DELETE statement inside a SELECT statement. Note that > RAISE() is a function and may appear where an expression can appear. > DELETE is a statement. > > Make it > > CREATE TRIGGER DeleteReferences BEFORE DELETE ON tableA > BEGIN > SELECT RAISE(ABORT, 'Id field referenced in Table-B') > where exists (SELECT * FROM tableB WHERE Ref = OLD.Id); > > DELETE FROM tableB WHERE Ref = OLD.Id; > END; > > If there are in fact no records in tableB that match the condition, > DELETE will safely do nothing. You don't need an explicit check first. > > Igor Tandetnik > ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------