is it possible to lock oracle 10g database table with C#/(ADO?).NET 2.0

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/15 22:09 UTC
Read the original article Hit count: 286

Filed under:
|
|

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!!
    }

-BR: Matti

© Stack Overflow or respective owner

Related posts about c#

Related posts about ADO.NET