Page 1 of 1

StartTransaction doesn't change AutoCommit

Posted: Mon 15 Feb 2010 12:51
by Moon Wolf
Hi,
I found on your forum this message about AutoCommit and StartTransaction:
UniDAC executes statements in the autocommit mode with Oracle unless you call the StartTransaction method. After you call this method autocommit is disabled. You should call Commit or Rollback to finish the transaction. After this autocommit is enabled.
When I'm using StartTransaction it doesn't change AutoCommit property. Here is a simple code for Oracle (10.2.0.1.0):

Code: Select all

 oracle->StartTransaction();
 oracle->ExecSQL("create table dummy(s varchar2(50))",0,0);
 oracle->Commit();
I'm using C++Builder 2010 and UniDAC 3.0.0.6.
I wonder if you could help me to solve this problem.
Regards, Max.

Posted: Mon 15 Feb 2010 13:08
by tobias_cd
Hi,
there are 3 things to take into account from my experience till now:
a) Oracle itself does not offer an "AutoCommit" option (SQL*plus just imitates it), so do not use/rely on it even if declared in UniDAC.
b) Oracle automatically commits upon successfull DDL statements, thus statements like "CREATE TABLE" etc. cannot be rolled back anyway.
You might consider using the TUniConnection.InTransaction property instead.
[EDIT] c) Upon UPDATE/DELETE/INSERT Oracle automatically starts a new transaction if not already active.
HTH,
Tobias

Posted: Mon 15 Feb 2010 13:24
by Moon Wolf
tobias_cd wrote:Hi,
there are 3 things to take into account from my experience till now:
a) Oracle itself does not offer an "AutoCommit" option (SQL*plus just imitates it), so do not use/rely on it even if declared in UniDAC.
b) Oracle automatically commits upon successfull DDL statements, thus statements like "CREATE TABLE" etc. cannot be rolled back anyway.
You might consider using the TUniConnection.InTransaction property instead.
[EDIT] c) Upon UPDATE/DELETE/INSERT Oracle automatically starts a new transaction if not already active.
HTH,
Tobias
Thanks for your reply,Tobias. It was usefull information for me.
Regards,Max.

Posted: Mon 15 Feb 2010 14:45
by Challenger
a) Oracle itself does not offer an "AutoCommit" option (SQL*plus just imitates it), so do not use/rely on it
even if declared in UniDAC.
The OCIExecute function supports OCI_COMMIT_ON_SUCCESS mode that commits the transaction after the statement was successfully executed.