Toby
Toby

Reputation: 592

Can I use Bind Variables with odp.net and Oracle 8i?

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();
  }

Upvotes: 1

Views: 1274

Answers (2)

Doug Porter
Doug Porter

Reputation: 7897

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

Upvotes: 1

APC
APC

Reputation: 146249

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.

Upvotes: 0

Related Questions