It is my understanding that the OracleDependency can be tied to monitor a query (not just a table). I make 2 command objects and 2 dependency objects but the query for both have different where clauses so they should be looking at 2 different subsets of this table.
I assign both of these dependency objects to the same callback. My expectations are that when I change something in the table that one of these dependency objects are watching that the OnChange event would fire for that one. I would then be able to do the following in the OnChange event to get the query that triggered teh change:
OracleDependency OraDep = (OracleDependency)sender;
string sql = (string)OraDep.RegisteredResources;
So I setup 2 queries against the same table with a different where clause value. Then I go into the DB and change one of them but to my surprise the OnChange even fires twice and the above code to get the query shows both queries.
Is there no way to have the dependency for a specific query and not the entire table? I thought I read somewhere you set it up for a specific query, where clause and all.
preguntado el 16 de mayo de 11 a las 19:05
Oracle change notification monitors the objects not queries. Any change on the table new record inserted, updated or deleted, new column added, renamed/dropped. Thats the reason why you are seeing notifications 2 times.
One way is to call the stored procedures instead of queries. Accept only 1 notification. Notification event e.info tells you what operation it is either insert/ update/ delete. So you can write an if condition to only respond to insert notifications and based on that you can call the appropriate sp or query.
Espero que esto ayude.