How to handle a missing feature of SQLite: disable triggers
?
I don't have it stored the name of triggers for a specific table.
For example how can I drop all triggers?
What would you do?
How to handle a missing feature of SQLite: disable triggers
?
I don't have it stored the name of triggers for a specific table.
For example how can I drop all triggers?
What would you do?
Maybe you can make a stored procedures for droping and creating them. Is that good for you ?
SQLite stores schema (meta) information in the built-in sqlite_master
table.
To get a list of available triggers use the below query:
SELECT name FROM sqlite_master
WHERE type = 'trigger' -- AND tbl_name = 'a_table_name'
I wrote a very simple extension function to set a boolean value to true or false.
And a function to retrieve this value (GetAllTriggersOn()).
With this function I can define all my triggers like:
CREATE TRIGGER tr_table1_update AFTER UPDATE ON TABLE1 WHEN GetAllTriggersOn()
BEGIN
-- ...
END