AssignConnect doesn't share transaction
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
AssignConnect doesn't share transaction
Hi.
I use odac90d17pro for RADStudioXE3.
In my project I have two independent modules (dll libraries). In first I create session by TOraSession. Next I pass that session pointer to second module. In second module I create another TOraSession and use AssignConnect.
In my previous version of ODAC (odac690d10pro) and BDS2006 when I started transaction in first module, I saw that same transaction in second module. Now, operation made in both session are invisible each other.
My intention is to have one transaction in both modules. Database modyfication in one module should be visible in second module.
Why it doesn't work now?
Regards
Wojciech Sitterlee
I use odac90d17pro for RADStudioXE3.
In my project I have two independent modules (dll libraries). In first I create session by TOraSession. Next I pass that session pointer to second module. In second module I create another TOraSession and use AssignConnect.
In my previous version of ODAC (odac690d10pro) and BDS2006 when I started transaction in first module, I saw that same transaction in second module. Now, operation made in both session are invisible each other.
My intention is to have one transaction in both modules. Database modyfication in one module should be visible in second module.
Why it doesn't work now?
Regards
Wojciech Sitterlee
Re: AssignConnect doesn't share transaction
Hello,
We cannot reproduce the problem. Please send a small project (both application and library) reproducing the problem to alexp*devart*com
We cannot reproduce the problem. Please send a small project (both application and library) reproducing the problem to alexp*devart*com
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
Re: AssignConnect doesn't share transaction
It is a difficult because source code is a part of a big project.
Could you agree that both session should be visible as one transaction in this case?
How exactly works 'AssignConnect'? Copy parameters of session? Copy transaction pointer?
Is it right way to pass session pointer to other module?
Could you agree that both session should be visible as one transaction in this case?
How exactly works 'AssignConnect'? Copy parameters of session? Copy transaction pointer?
Is it right way to pass session pointer to other module?
Re: AssignConnect doesn't share transaction
Hello,
There is a sample of a console application and a library demonstrating work with transaction in a DLL. Please enter correct server names, password, login and your PC name, execute the application and let us know the results.
There is a sample of a console application and a library demonstrating work with transaction in a DLL. Please enter correct server names, password, login and your PC name, execute the application and let us know the results.
Code: Select all
library DllPrj;
uses
SysUtils,
Classes,
Ora;
var
InternalSession: TOraSession;
procedure AssignSession(Session: TOraSession); cdecl;
begin
InternalSession := TOraSession.Create(nil);
InternalSession.AssignConnect(Session);
end;
function CheckTransaction: Boolean;
begin
Result := InternalSession.InTransaction;
end;
procedure SessionFree; cdecl;
begin
InternalSession.Free;
end;
exports
AssignSession,
CheckTransaction,
SessionFree;
begin
end.
Code: Select all
program ConsolePrj;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Variants,
Ora;
type
TAssignSession = procedure (Session: TOraSession); cdecl;
TCheckTransaction = function: boolean; cdecl;
TSessionFree = procedure; cdecl;
var
OraSession, OraSessionCheck: TOraSession;
hDLL:HModule;
AssignSession: TAssignSession;
CheckTransaction: TCheckTransaction;
SessionFree: TSessionFree;
begin
OraSession := TOraSession.Create(nil, 'login/passwd@SID');
try
OraSession.Connect;
OraSession.StartTransaction;
hDLL := 0;
hDLL := LoadLibrary('DllPrj.dll');
try
if hDLL <> 0 then begin
@AssignSession := GetProcAddress(hDLL, 'AssignSession');
if @AssignSession <> nil then
AssignSession(OraSession)
else
Exit;
@CheckTransaction := GetProcAddress(hDLL, 'CheckTransaction');
if @CheckTransaction <> nil then begin
OraSessionCheck := TOraSession.Create(nil, 'login/passwd@SID as SYSDBA');
try
OraSessionCheck.Connect;
OraSessionCheck.ExecSQL('begin select count(*) into :p1 FROM v$transaction t, v$session s WHERE t.ses_addr = s.saddr AND MACHINE = ''PC_NAME''; end;',[0]);
Writeln(Format('Dll InTransaction: %s; Transaction Count %d',[VarToStr(CheckTransaction), OraSessionCheck.SQL.ParamByName('p1').AsInteger]));
finally
OraSessionCheck.Free;
end;
end
else
Exit;
@SessionFree := GetProcAddress(hDLL, 'SessionFree');
if @SessionFree <> nil then
SessionFree;
end;
finally
FreeLibrary(hDLL);
end;
finally
OraSession.Free;
end;
Readln;
end.
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
Re: AssignConnect doesn't share transaction
Results:
"Dll InTransaction: True; Transaction Count 0"
Edit:
Sorry, I didn't change machine name in query.
Results:
"Dll InTransaction: True; Transaction Count 1"
"Dll InTransaction: True; Transaction Count 0"
Edit:
Sorry, I didn't change machine name in query.
Results:
"Dll InTransaction: True; Transaction Count 1"
Re: AssignConnect doesn't share transaction
Hello,
Most probably, you have specified an incorrect PC name in the MACHINE = 'PC_NAME' query, therefore the number of transactions is 0.
Most probably, you have specified an incorrect PC name in the MACHINE = 'PC_NAME' query, therefore the number of transactions is 0.
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
Re: AssignConnect doesn't share transaction
Yes, I wrote in previous post about that mistake. Result is 1.
Re: AssignConnect doesn't share transaction
Hello,
This result means, that one and the same transaction is used when assigning session with the AssignConnect method.
This result means, that one and the same transaction is used when assigning session with the AssignConnect method.
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
Re: AssignConnect doesn't share transaction
We have found the problem. There was anywhere else.
You had to change apparently, something with AutoCommit property in TOraQuery. Despite passing session pointer from first modul, opening query in second module caused openig new transaction. That's why we have two transactions.
Anyway thank you for your help
You had to change apparently, something with AutoCommit property in TOraQuery. Despite passing session pointer from first modul, opening query in second module caused openig new transaction. That's why we have two transactions.
Anyway thank you for your help

Re: AssignConnect doesn't share transaction
Hello,
Please modify the code I have sent you, so that the described behaviour is reproduced, and send it back, in order for me to be able to investigate the problem.
Please modify the code I have sent you, so that the described behaviour is reproduced, and send it back, in order for me to be able to investigate the problem.
-
- Posts: 27
- Joined: Fri 12 Feb 2010 07:44
Re: AssignConnect doesn't share transaction
Hello
I can't reproduce that situation in your example. It works
In my C++ code I had to change one line of code:
q->AutoCommit = false
to:
q->AutoCommit = q->Session->AutoCommit;
where 'q->Session' is comming from outside library and also is 'false'.
I can't reproduce that situation in your example. It works

In my C++ code I had to change one line of code:
q->AutoCommit = false
to:
q->AutoCommit = q->Session->AutoCommit;
where 'q->Session' is comming from outside library and also is 'false'.
Re: AssignConnect doesn't share transaction
Hello,
This problem may be directly due to the IDE. Try to reproduce the problem on another IDE version or send us your С++ project - and we will check this behaviour on various IDEs.
This problem may be directly due to the IDE. Try to reproduce the problem on another IDE version or send us your С++ project - and we will check this behaviour on various IDEs.