An external application come to my database for inserting row in a Sql server table.
I have a web application on my own, and I want on each insert in this table, do some treatement server side.
My idea is to create a trigger on insert on the table, and then call appropriate function.
What is the best way to do this ?
I use framework 3.5 with LINQ to SQL, and a SQL Server 2005 database.
Edit : Thank you for the answers. SQL Server CLR integration doesn't do it. The few libraries supported doesn't meet me requirement.
The table I have to log will take a new record every 5 minutes perhaps, not so much. Maybe I can have a job listening at the table every minute, look at the ID, take all the new ID, do my treatement. Is my solution not too ugly ?
We can call a C function from Python program using the ctypes module.
Just declare the C function extern "C" (in your C++ code) and call it (from your C or C++ code). For example: // C++ code. extern "C" void f(int); // one way.
The C++ language provides mechanisms for mixing code that is compiled by compatible C and C++ compilers in the same program. You can experience varying degrees of success as you port such code to different platforms and compilers.
The most basic method for calling C code from R is to use the . C() function described in the System and foreign language interfaces section of the Writing R Extensions manual. Other methods exist including the . Call() and .
Use SQL Server CLR integration.
If your function is going to take a long time to run, or going to access resources which aren't part of the same database, you might want to consider decoupling the function call from the trigger (so that the original statement that caused the trigger to fire can complete).
In that case, you might want to look at Service Broker, or just use a separate table to queue the requests to call the function (and use a SQL Agent job to dequeue these requests and call the function).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With