views:

522

answers:

2

I'm new to triggers so I apologize if this is a stupid question.

Is it possible to have a trigger (or some other database mechanism) raise an event in another process. For instance, I need an application to be made aware of a certain activity (update in a specific table with specific data), but I'd rather not have that process poll the database. Does anyone know if it is possible for a trigger (or maybe a stored procedure) to raise an event or some other asynchronous notification mechanism in another process?

[NOTE: Recipient application is written in C# and database is sqlite]

A: 

Yes, write a trigger that fires on your criteria and calls an external function that you've defined. I forget what SQLite calls custom external functions, but they're there.

They're just called application defined functions, see http://www.sqlite.org/c3ref/create_function.htmlI'd also take issue with Thomas's notion that SQLite has very basic trigger support. Version 3's triggers can do pretty much anything any other RDBMS can do and not all RDBMS's support external functions.
A: 

It may be possible with some RDBMS, but not with SQLite. SQLite support for triggers is VERY basic...

EDIT : actually, it might be possible, but the actual notification would be done by your program, not by SQLite itself. You could define a function in C# that you would map to a SQLite function, and call that function in the trigger.

Thomas Levesque