StartTransaction doesn't change AutoCommit

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Moon Wolf
Posts: 4
Joined: Thu 04 Feb 2010 13:24

StartTransaction doesn't change AutoCommit

Post by Moon Wolf » Mon 15 Feb 2010 12:51

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.

tobias_cd
Posts: 56
Joined: Thu 18 Dec 2008 22:10

Post by tobias_cd » Mon 15 Feb 2010 13:08

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

Moon Wolf
Posts: 4
Joined: Thu 04 Feb 2010 13:24

Post by Moon Wolf » Mon 15 Feb 2010 13:24

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.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Mon 15 Feb 2010 14:45

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.

Post Reply