Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How write begin transaction sql statement for Oracle

KarryMay 26 2011 — edited May 26 2011
Dear All:

In MSSQL server, use "Begin Transaction" to start a transaction, I write the following codes for Oracle, but I found it auto commit when execute query even call rollback. What can I do the transaction can be valid?

OleDbConnection conn = new OleDbConnection();
OleDbCommand command = null;

//Connect to server

string connectString = "Provider=OraOLEDB.Oracle;User ID=" + userID + ";Password=" + pwd
+ ";Data Source=" + dataSource + ";Pooling=False";
conn.ConnectionString = connectString;
conn.Open();
command = conn.CreateCommand();

//Execute transaction

command.CommandText = "Set transaction name 't1'" //or command.CommandText = "SAVEPOINT t1"

command.ExecuteNonQuery();

command.CommandText = "delete from table";

command.ExecuteNonQuery(); //I found the record already be deleted but I not call commit

//call rollback, but the records still be deleted

command.CommandText = "rollback"; //or = "commit"

command.ExecuteNonQuery();
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2011
Added on May 26 2011
3 comments
1,080 views