Mukesh's Blog
Wednesday, August 22, 2012
Tuesday, August 21, 2012
Thursday, July 12, 2012
Friday, December 3, 2010
Data base change Notification In Oracle 11g with odp.net 11
Data base change notification can be implementd by two way:
- QCN(Query Change Notification)
- OCN (Object Change Notification)
1.QCN(Query Change Notification)
In Query change notification user can register the notification on a query result set.when ever there is any insert/update/delete command execute on this result set , client will get change notification.Sample Code:
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleDependency dependency = new OracleDependency();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "Select * from Test_dummy where rownum > 5";
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
dependency.AddCommandDependency(command);
command.Notification.IsNotifiedOnce = false;
command.AddRowid = true;
command.ExecuteNonQuery();
con.Close();
con.Dispose();
Console.ReadLine();
static void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs)
{
try
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Table has been Changed");
Console.WriteLine(eventArgs.Source.ToString());
Console.WriteLine(eventArgs.Info.ToString());
Console.WriteLine(eventArgs.Source.ToString());
Console.WriteLine(eventArgs.Type.ToString());
DataTable dt = eventArgs.Details;
PrintDataTable(dt);
Console.ForegroundColor = ConsoleColor.White;
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
2.OCN(Object Change Notification)
If an application registers a query for object change notification (OCN), the database sends the application an OCN whenever a transaction changes an object associated with the query and commits, whether or not the result of the query changed.Sample Code
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleDependency dependency = new OracleDependency();
dependency.QueryBasedNotification = false;
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "Select * from test_dummy";
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
dependency.AddCommandDependency(command);
command.Notification.IsNotifiedOnce = false;
command.AddRowid = true;
command.ExecuteNonQuery();
con.Close();
con.Dispose();
static void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs)
{
try
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Table has been Changed");
Console.WriteLine(eventArgs.Source.ToString());
Console.WriteLine(eventArgs.Info.ToString());
Console.WriteLine(eventArgs.Source.ToString());
Console.WriteLine(eventArgs.Type.ToString());
DataTable dt = eventArgs.Details;
PrintDataTable(dt);
Console.ForegroundColor = ConsoleColor.White;
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
For more Information http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28424/adfns_cqn.htm#CHDEFIFJ
Thursday, November 4, 2010
FAQ on OOPS concepts
Ans.
a). Structs are value types but class are referenced type.
b). All struct types implicitly inherit from the class System.ValueType
c).Assignment to a variable of a struct type creates a copy of the value being assigned .
d).The default value of a struct is the value produced by setting all value type fields to their default value and all reference type fields to null.
e).Boxing and unboxing operations are used to convert between a struct type and object.
f).The meaning of this is different for structs.
g).Instance field declarations for a struct are not permitted to include variable initializers.
h).A struct is not permitted to declare a parameterless instance constructor.
i).A struct is not permitted to declare a destructor.
For more info please goto :http://msdn.microsoft.com/en-us/library/aa288471(VS.71).aspx