[问题记录.Oracle/odp.net]数据库变化通知(Database Change Notification)的使用限制

Oracle提供了数据库变化通知(Database Change Notification)特性,方便我们感知数据表中特定数据的变化。但实际使用时还是建议先研读它提供的技术文档(参见-ODP 开发指导),避免掉入一些坑。

问题描述:

按查询条件进行的订阅,但实际情况确是——在不符合条件的数据记录发生变化时,也收到了消息通知。
 

问题原因:

订阅SQL中Select部分包含了blob类型的字段,而想实现预期的效果列只能是Varchar2与Number类型。
至于为什么?查阅Oracle官方文档后就清楚了,以下是一些解读(2018.02月份同事验证的):

数据库变化通知(Database Change Notification)功能从Oracle11gODP.net 11g开始支持两种模式:

a.     基于查询(Query-based,允许在数据库中所选行发生更改时通知应用程序。OracleDependency依赖对象添加的OracleCommand对象对应SQL语句示例:select ename from emp where empno ='1')

b.    基于对象( Object-based,允许通知应用程序包含所选行的表中发生的任何更改。OracleDependency依赖对象添加的OracleCommand对象对应SQL语句示例:select * from emp

只有满足以下条件,数据库变化通知基于查询的模式才生效:
1)The Oracle database version is at least 11.1.
>> Oracle版本至少是 11.1
2)The select list contains no other column data types other than VARCHAR2 and NUMBER.
>>列的类型只支持 VARCHAR2 and NUMBER.
3)The COMPATIBLE initialization parameter of the database is set to at least 11.0.0 and Automatic Undo Management (AUM) is enabled (the default).
>> COMPATIBLE 初始化参数至少为11.0.0与自动撤销管理启用(没有详细了解,缺省安装则是此设置)

If 1) is not met, the notification is registered as object-based for backward compatibility.
>>如果条件1不符合,则向后兼容数据库变化通知注册为基于对象的模式
If 2) and other documented restrictions are not met, the notification is registered as object-based since ODP.NET uses the best-effort mode.
>>如果条件2不符合,则数据库变化通知注册为基于对象的通知模式
If 3) is not met, an error is returned upon registration.
>>如果条件3不符合,注册会报错

 

附:官方说明原文《ODP 开发指导

原创文章 33 获赞 26 访问量 4万+

猜你喜欢

转载自blog.csdn.net/debug_fan/article/details/103390740