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]
[注意:收件人应用程序是用C#编写的,数据库是sqlite]
2 个解决方案
#1
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.
是的,编写一个触发器,触发您的条件并调用您定义的外部函数。我忘了SQLite所谓的自定义外部函数,但它们就在那里。
#2
It may be possible with some RDBMS, but not with SQLite. SQLite support for triggers is VERY basic...
某些RDBMS可能是可能的,但SQLite则不行。 SQLite对触发器的支持非常基础......
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.
编辑:实际上,它可能是可能的,但实际的通知将由您的程序完成,而不是由SQLite本身完成。您可以在C#中定义一个映射到SQLite函数的函数,并在触发器中调用该函数。
#1
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.
是的,编写一个触发器,触发您的条件并调用您定义的外部函数。我忘了SQLite所谓的自定义外部函数,但它们就在那里。
#2
It may be possible with some RDBMS, but not with SQLite. SQLite support for triggers is VERY basic...
某些RDBMS可能是可能的,但SQLite则不行。 SQLite对触发器的支持非常基础......
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.
编辑:实际上,它可能是可能的,但实际的通知将由您的程序完成,而不是由SQLite本身完成。您可以在C#中定义一个映射到SQLite函数的函数,并在触发器中调用该函数。