is it possible to lock oracle 10g database table with ADO.NET?
Posted
by matti
on Stack Overflow
See other posts from Stack Overflow
or by matti
Published on 2010-03-05T11:41:38Z
Indexed on
2010/03/23
16:33 UTC
Read the original article
Hit count: 316
I have a table that contains a maximum value that needs to be get and set by multiple programs. How can I lock the table for a while when old value is got and new is updated in C#? In other words:
string sql = "lock table MaxValueTable in exclusive mode";
using (DbCommand cmd = cnctn.CreateCommand())
{
cmd.CommandText = sql;
// execute command somehow!!
}
maxValue = GetMaxValue();
SetMaxValue(maxValue + X);
sql = "lock table MaxValueTable in share mode";
using (DbCommand cmd = cnctn.CreateCommand())
{
cmd.CommandText = sql;
// execute command somehow!!
}
© Stack Overflow or respective owner