0

I have a server application and client application that the database is shared within a network, What I want to happen is that when the client application inserted/updated/deleted data from a specific table I want the server to be alerted and run some code on it.

How can I possibly achieve this? Any ideas will be a big help! thanks :-)

cheol.lui
  • 359
  • 1
  • 6
  • 18

2 Answers2

3

Use a trigger for push notifications, or keep lastModified information to check for pull notification. You probably want the former,

edit You can use sys_exec('program') from https://github.com/mysqludf/lib_mysqludf_sys to call an external program from a trigger. Just use that to call whatever server code you have. Examples and setup instructions can be found via google. e.g. http://bernardodamele.blogspot.com.au/2009/01/command-execution-with-mysql-udf.html

Sysyphus
  • 1,061
  • 5
  • 10
  • So, how can I catch that trigger thing on my application? – cheol.lui Apr 10 '13 at 01:04
  • http://stackoverflow.com/questions/1467369/invoking-a-php-script-from-a-mysql-trigger has some answers on how to call a different program from a trigger. You can use sys_exec to call an external program, which then runs whatever code you wanted. – Sysyphus Apr 10 '13 at 01:31
  • @cheol.lui Updated answer with some more information on how to use sys_exec, and where to get it from. – Sysyphus Apr 10 '13 at 01:38
2

You didn't say what type of database you were using. If you were using MS SQL Server, I'd suggest having a look at their StreamInsight which lets you write "adapters" that deal with data in real-time as it is saved.

I don't know if you'll be able to access/incorporate that in your existing server application though. But depending on what you're trying to achieve, you might not have to.

Fooksie
  • 480
  • 7
  • 25