Page 1 of 1

Multiple transactions with OraSession.Assingconnect

Posted: Thu 28 Jun 2007 13:47
by mufalo
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)
);

versions..

Posted: Thu 28 Jun 2007 13:50
by mufalo
I use ODAC Version 5.80.0.41, Delphi 7 and Oracle 10g.

Posted: Mon 02 Jul 2007 09:17
by Challenger
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.