-
Notifications
You must be signed in to change notification settings - Fork 681
TRIGGER
Andrey Gershun edited this page Dec 31, 2015
·
6 revisions
Syntax:
CREATE TRIGGER triggerName (BEFORE|AFTER|INSTEAD OF) (INSERT|DELETE|UPDATE) ON tableName (Statement|Function)
Example A
alasql.fn.check = function(r) {
if(r.n == 42) return false; // Do not insert on this number
};
alasql('CREATE TRIGGER mytrigger BEFORE INSERT ON mytable check');
Example B
alasql.fn.onchange = function(r) {
if(r.a == 123) console.log('Observable event!');
};;
alasql('CREATE TABLE one (a INT)');
alasql('CREATE TRIGGER two BEFORE INSERT ON one CALL onchange()');
alasql('INSERT INTO one VALUES (123)'); // This will fire onchange()
Limitations:
- No
INSTEAD OF DELETE
- No
AFTER DELETE
-
BEFORE DELETE
can not prevent record from deletion
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo