Created
August 5, 2014 09:43
-
-
Save ddmitov/dc19a325ea578ff8f9a7 to your computer and use it in GitHub Desktop.
Example SQLite triggers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER calculate_vat_new AFTER INSERT ON inventory | |
BEGIN | |
UPDATE inventory SET PRICE_VAT = new.PRICE/100*20+new.PRICE WHERE id = new.id; | |
END; | |
CREATE TRIGGER calculate_vat UPDATE OF PRICE ON inventory | |
BEGIN | |
UPDATE inventory SET PRICE_VAT = new.PRICE/100*20+new.PRICE WHERE id = old.id; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment