扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:小溪明净 来源:天极开发 2007年10月22日
关键字: Oracle 10g 功能 变化通知 ORACLE
static void Main(string[] args) { string sql = "select first_name, last_name, salary from employees where employee_id = 149"; string constr = "User Id=hr;Password=hr;Data Source=oramag;Pooling=false"; OracleConnection con = new OracleConnection(constr); con.Open(); OracleCommand cmd = new OracleCommand(sql, con); OracleDependency dep = new OracleDependency(cmd); dep.OnChange += new OnChangeEventHandler(OnDatabaseNotification); cmd.ExecuteNonQuery(); while (notificationReceived == false) { Console.WriteLine("Waiting for notification..."); System.Threading.Thread.Sleep(2000); } cmd.Dispose(); con.Dispose(); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); } public static void OnDatabaseNotification(object src, OracleNotificationEventArgs args) { Console.WriteLine("Database Change Notification received!"); DataTable changeDetails = args.Details; Console.WriteLine("Resource {0} has changed.", changeDetails.Rows[0]["ResourceName"]); notificationReceived = true; } |
grant change notification to hr; |
using System.Threading; using System.Data; using Oracle.DataAccess.Client; |
Waiting for notification... |
update employees set salary = salary+10 where employee_id = 149; commit; |
Database Change Notification received! Resource HR.EMPLOYEES has changed. |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者