Hi List
I've got a Problem on deleting records via trigger. Table "tb_categorie" references itself to arrange data in a tree-structure like:

cars            (tag=1,parent_tag=0)
 vans           (tag=2,parent_tag=1)
  pickups       (tag=3,parent_tag=2)
  van           (tag=4,parent_tag=2)
 sportscars     (tag=5,parent_tag=1)
  Porsche       (tag=6,parent_tag=5)
  Maserati      (tag=7,parent_tag=5)
Bikes           (tag=8,parent_tag=0)
 Yamaha         (tag=9,parent_tag=8)

When deleteing I need an update of table "tb_article" and a delete on "tb_categorie_locale". e.g.:
DELETE FROM tb_categorie WHERE tag=5;
Does remove the tags 5,6,7 in tb_categorie, as expected, but: no Update is done to tb_article. In "tb_categorie_locale" only one row is deleted (tb_categorie_tag=5) all other rows remains in the table. What's wrong with the trigger?

Thanks for Your Help in Advance
Uwe

Here's what I'm responsible for:

CREATE TABLE tb_categorie (
tag INTEGER PRIMARY KEY AUTOINCREMENT
,parent_tag INTEGER REFERENCES tb_categorie(tag) NOT NULL DEFAULT 0
,nodepath TEXT
,cat_level varchar(10)
);

CREATE TRIGGER trg_categorie_del BEFORE DELETE ON tb_categorie
FOR EACH ROW
BEGIN
 DELETE FROM tb_categorie_locale WHERE tb_categorie_tag=OLD.tag;
 UPDATE tb_article SET tb_categorie_tag=0 WHERE tb_categorie_tag=OLD.tag;
 DELETE FROM tb_categorie WHERE parent_tag=OLD.tag;
END;

CREATE TABLE tb_categorie_locale(
tb_categorie_tag INTEGER REFERENCES tb_categorie(tag)
,tb_language_tag INTEGER REFERENCES tb_language(tag) DEFAULT 1
,parent_tag INTEGER
,name VARCHAR(70) NOT NULL
);
CREATE UNIQUE INDEX ixd_categorie ON tb_categorie_locale (parent_tag,name);

CREATE TABLE tb_article(
tag INTEGER PRIMARY KEY AUTOINCREMENT
,tb_categorie_tag INTEGER UNSIGNED NOT NULL REFERENCES tb_categorie(tag)
,artnr VARCHAR(50) NOT NULL
,ek_price FLOAT NOT NULL
,ean INTEGER UNSIGNED NULL DEFAULT 0
,weight DOUBLE
);
CREATE UNIQUE INDEX idx_artnr ON tb_article(artnr);

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to