Oracle change notification doesnt work.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
berkrat
Posts: 1
Joined: Mon 28 Nov 2011 10:07
Location: Germany

Oracle change notification doesnt work.

Post by berkrat » Mon 28 Nov 2011 12:44

Hi,

with the following code, I try to use the Oracle change notification:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Devart.Data.Oracle;
using System.Data;

namespace DBEventBroker
{
class Eventbroker
{
public void TestOracleChangeNotification()
{
OracleCommand cmd;
OracleDependency dep;
DataSet ds = new DataSet();
string tablename = "table";
string sqlSelect = "select EventId, Event, TestCol FROM E$Test where EventID = 1 ";
OracleConnection con = new OracleConnection("User Id=TestUser;Password=password;Data Source=localDB");
cmd = new OracleCommand(sqlSelect);
OracleDependency.Port = 1521;
dep = new OracleDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;
cmd.Notification.RowLevelDetails = true;
cmd.Notification.Timeout = 0;
dep.OnChange += new OnChangeEventHandler(OnMyNotificaton);
OracleDataAdapter da = new OracleDataAdapter(cmd);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
try
{
da.Fill(ds, tablename);
}
catch (Exception ex)
{
string message = ex.Message;
}
}


public static void OnMyNotificaton(object src, OracleNotificationEventArgs args)
{
//args.Details is always NULL
if ( args.Details != null && args.Details.Rows.Count > 0)
{
string type = Enum.GetName(typeof(OracleNotificationInfo), args.Details.Rows[0].ItemArray[1]);
if (type == OracleNotificationInfo.Delete.ToString())
return;
}
else
return;

DataRow Row = args.Details.Rows[0];
DataRowCollection detailRows = args.Details.Rows;
}
}
}

If I made an Insert to E$Test, the Oracle database fires an event, which is caught by the method OnMyNotificaton.
But the DataTable Details in OracleNotificationEventArgs is always null (see comment above).

Are there any settings in Oracle database which I have to change or is something wrong in my C# code?

It would be nice if you could help me.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 29 Nov 2011 13:14

Thank you for your report. We have reproduced the issue. We will notify you when it is fixed.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 29 Nov 2011 13:41

This is a settings issue. Please turn off the query based notification:

Code: Select all

dep = new OracleDependency(cmd); 
-->

Code: Select all

dep = new OracleDependency(cmd); 
dep.QueryBasedNotification = false;

Post Reply