Last active
August 12, 2024 08:35
-
-
Save ddmitov/dc19a325ea578ff8f9a7 to your computer and use it in GitHub Desktop.
Example SQLite triggers
This file contains hidden or 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_insert 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 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