WARNING: This server is unstable and will be retired in the next days.
If you want to keep this forum available, please request immediately a migration
on the
Nabble Support forum.
Forums that don't receive any migration request will be deleted forever.
Multiple WHENs in triggers
Hi all,
I'm trying to put in a series of conditionals into a trigger, along the lines of
--
CREATE TRIGGER UpdateSaleItemDescription AFTER INSERT ON SaleItem
WHEN NEW.SaleItem_ID='7'
BEGIN
UPDATE SaleItem SET SaleItem_Description='This is seven' WHERE SaleItem_ID=NEW.SaleItem_Id;
END;
WHEN NEW.SaleItem_ID<>'7'
BEGIN
UPDATE SaleItem SET SaleItem_Description='This is not seven' WHERE SaleItem_ID=NEW.SaleItem_Id;
END;
INSERT INTO SaleItem(SaleItem_TaxRate) VALUES('0');
INSERT INTO SaleItem(SaleItem_TaxRate) VALUES('0');
--
(obviously simplified for ease of description here).
But this isn't working - I get a syntax error near WHEN (the second one). If I remove the four lines starting WHEN NEW.SaleItem_ID='8' then it works ok.
Can I use a SELECT CASE statement here? If so, what's the syntax? I can't believe that SQLite only allows only one trigger with only one WHEN per action... can it?
Thanks in advance,
Hamish