Ran wrote:
Hi all,
I use many triggers and for debugging purposes I wanted to know which one is
triggered and when.
At first I thought that if I write a SELECT within the BEGIN-END block, this
SELECT results will be printed (at least when using sqlite3 command line
program). But this didn't work. So I wrote a simple print method that takes
one argument and printf it to the standard out. This works and actually
solves my problem.
I can write something like:
create trigger bla after delete on foo
begin
select print('bla trigger is triggered');
....
end;
But I still wonder - this solution is quite simple, yet very useful - so I
suspect I missed an existing feature. Is there a builtin feature like this?
Thanks,
Ran.
Ran,
There isn't a way to get this output printed directly, but you can
easily create a log of your applications activity in a table and then
use a select to dump the table.
create table log(event text);
create trigger ...
begin
insert into log values('blah blah blah...');
...
end;
Then after your program stops, or using another connection to the
database, you can dump the log using select * from log. If you want you
can event get more sophisticated and add a timestamp field to your log,
or add other fields to track important internal state information.
HTH
Dennis Cote