Multiple transactions with OraSession.Assingconnect

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mufalo
Posts: 15
Joined: Mon 21 Nov 2005 18:00

Multiple transactions with OraSession.Assingconnect

Post by mufalo » Thu 28 Jun 2007 13:47

Hello !
I Have a problem with multiple transactions in use of 2 OraSession, since second OraSession AssignConnect the first OraSession.
the code I try:
OraSession1.AutoCommit:=False;
OraSession1.Connect;
Application.CreateForm(TDM, DM);
DM.OraSession1.AutoCommit:=False;
DM.OraSession1.AssignConnect(OraSession1);
OraSession1.StartTransaction;
OraQuery1.SQL.Text:='insert into teste (id, texto) values (1, ''rollback'')';
OraQuery1.ExecSQL;
DM.OraQuery1.SQL.Text:='insert into teste (id, texto) values (2, ''commit'')';
DM.OraQuery1.ExecSQL;
DM.OraSession1.commit;
OraSession1.Rollback;

I need that DM.OraSession1.commit doesn´t affect the OraSession1.

the result:
SQL> select * from teste;
ID TEXTO
---------- --------------------------------------------------
1 rollback
2 commit

the result I need:
SQL> select * from teste;
ID TEXTO
---------- --------------------------------------------------
2 commit




This sample are in
http://www.alternativasistemas.com.br/testecommit.zip

Create Script:
create table teste (
id number(9),
texto varchar2(50)
);

mufalo
Posts: 15
Joined: Mon 21 Nov 2005 18:00

versions..

Post by mufalo » Thu 28 Jun 2007 13:50

I use ODAC Version 5.80.0.41, Delphi 7 and Oracle 10g.

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

Post by Challenger » Mon 02 Jul 2007 09:17

When calling the DM.OraSession1.AssignConnect method you make DM.OraSession1 use the same sevice context as OraSession1. Therefore these two objects manage the same Oracle session. Oracle doesn't support parallel transactions. So the only way to achieve the behavior you want is to use two separate Oracle sessions.

Post Reply