views:

24

answers:

2

Hello,

due to the lack of an testing environment I need to know if the following scenario will work:

I have installed the Oracle Data Provider for .Net version 9.2.0.4. In production I'll have to communicate from my C# application with two Databases, an Oracle 8i and 9i.

Does Oracle 8i support Bind Variables in this scenario?

I'm likely to use code similar to the following:

Thanks in advance!

OracleCommand cmd = con.CreateCommand();

  OracleTransaction txn = con.BeginTransaction();

  try {
    cmd.CommandText = "update MayJun2009 " +
                      "set balance = balance + :1 " +
                      "where account_id = :2";

      OracleParameter pBalance = new OracleParameter();
    pBalance.OracleDbType = OracleDbType.Int32;
    OracleParameter pAccount = new OracleParameter();
    pAccount.OracleDbType = OracleDbType.Int32;

    cmd.Parameters.Add(pBalance);
    cmd.Parameters.Add(pAccount);

    pBalance.Value = -500;
    pAccount.Value = 1;

    cmd.ExecuteNonQuery();

    pBalance.Value = 500;
    pAccount.Value = 2;

    cmd.ExecuteNonQuery();

    txn.Commit();
  }
  catch (OracleException ex) {
    txn.Rollback();
  }
+1  A: 

Yes, that example should be using bind variables, shouldn't matter whether it is Oracle 8 or 9i. You could do a database trace to verify for certain. Another example of binds for C# is here:

Building an Oracle Data Provider for .NET Application

Dougman
Thank you very much for verifying! I was just worried that ODP and bind variables are incompatible with Oracle 8. Now I can keep building my application with bind variables with a clear conscience. Otherwise I would have had to wait for a trial environment to get available to try the scenario out.
A: 

Providing your application is using a 9iR2 client or higher, which appears to be true in your case, you can connection to Oracle8i (or even straight Oracle8) databases.

APC