I have a daemon written in C under linux and i want the daemon to be notified when a table inside an Oracle database has changed (update or insert in the table). It seems that a Trigger
or dbms_scheduler
may help, any ideas (snippets of code with an infinite while loop for example)? Thanks.
Asked
Active
Viewed 101 times
1

iPadDevloperJr
- 992
- 3
- 20
- 34
-
2A better approach would be to use the DBMS_AQ package. You can have the trigger post to a queue, and the c client wait for a queue entry to read back. google DBMS_AQ and read the oracle docs about it. It is more efficient than constantly polling a table. Here is an example using OCI - http://docs.oracle.com/cd/B10500_01/appdev.920/a96587/qsample.htm It is a lot of coding to do in C. What do you need to do with the notification data? If it is more database processing, then you can most likely do it all in the database with pl/sql. – OldProgrammer Jul 07 '13 at 18:58
-
Also, you don't mention what db access library you are using in your C program to access the database. Please specify. – OldProgrammer Jul 07 '13 at 18:59
-
@OldProgrammer : i'm using Oracle PRO*C – iPadDevloperJr Jul 07 '13 at 19:04
-
OK, then that makes it a lot easier. Take a look at DBMS_AQ. – OldProgrammer Jul 07 '13 at 19:06
-
@OldProgrammer : Thanks but it seems that ther's no API for PRO*C just for OCI! – iPadDevloperJr Jul 07 '13 at 19:34
-
You can call pl/sql in pro*c. Good luck. – OldProgrammer Jul 07 '13 at 19:35