
The program runs ok because in fact these categories are orphans (their ParentID field points nowhere - their parent row is deleted). It is just garbage.
The possible cause of the problem is the recursive trigger...
Code: Select all
CREATE TRIGGER delete_cat DELETE ON Tags
BEGIN
DELETE FROM Tags
WHERE ParentID = OLD.TagID;
END
The fix is obvious: make it an AFTER trigger:
Code: Select all
CREATE TRIGGER delete_cat AFTER DELETE ON Tags
BEGIN
DELETE FROM Tags
WHERE ParentID = OLD.TagID;
END