views:

196

answers:

3

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?

+1  A: 

Maybe you can make a stored procedures for droping and creating them. Is that good for you ?

anthares
I don't have stored the name of the triggers. So I need to get all triggers specific for a table.
Pentium10
+4  A: 

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'
Nick D
+1  A: 

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
ralf.w.