Page 1 of 1

ODAC and DLL not working?

Posted: Thu 01 Dec 2011 13:33
by Kaus Media
Hi there,
I have upgraded an old project that worked perfectly well with XP/D2009/ODAC6 which creates reports, each report are launched with the use of a separate DLL for each report.
Unfortunately, since a simple upgrade to W7/DelphiXE/ODAC 7 & 8, I am not able to make it work anymore?!
The query always works fine the first time it is launched but I get violation errors or process hanging after several times?!
It seems that ODAC 7&8 does not properly frees some resources when executed inside a DLL??? (That same query works perfectly fine in a standard compiled exe file!)
I have created a very basic project w/a DLL to show you the trouble: https://www.br-e-a-s-t.org/uploads/DebugODAC.zip
Please help, I have lost days with that problem...
Huge thanks,

Posted: Mon 05 Dec 2011 09:46
by AlexP
Hello,

We've downloaded your project, but we did not encounter any problems with it when working. Please describe when exactly and what errors occur on working with Dll, and also give us text or screenshot of these errors.

Weird solution !?!?!? Definitely some ODAC bug...

Posted: Mon 12 Dec 2011 09:39
by Kaus Media
Don't ask me why... But inside a DLL, this one works fine:

Var fDatabase: TOraSession;
Var sqlQuery: TOraQuery;
procedure Create (Database: TOraSession); stdcall;
begin
fDatabase := Database;
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fDatabase;
end;
procedure Destroy; stdcall;
begin
sqlQuery.Free;
end;
procedure Query (strQuery: string); stdcall;
begin
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
end;
exports Create, Destroy, Query;

And this one doesn't
(Produce unending loop on the second call to the query):

Var fDatabase: TOraSession;

procedure Create (Database: TOraSession); stdcall;
begin fDatabase := Database; end;

procedure Query (strQuery: string); stdcall;
Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
sqlQuery.Free;
end;
exports Create, Query;

Well, now at least I have a solution to make this damn code work...

Posted: Mon 12 Dec 2011 13:01
by AlexP
Hello,

As I've written you earlier, the problem does not occur even if the local variable is used. Maybe adding the try..finally block will help you:

Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
try
sqlQuery.Open;
sqlQuery.Close;
finally
sqlQuery.Free;
end;

??? Solved...

Posted: Thu 15 Dec 2011 11:00
by Kaus Media
I have created a virtual XP machine and reinstalled all the software (XE, ODAC 8.1) and everything works.

It seems then it is related to my Delphi/Odac installation (x32/x64 or file versioning trouble...). Strange, but at least I can compile properly now...

Thanks anyway for your help...

Posted: Tue 20 Dec 2011 11:38
by bork
Hello

This issue can occur if DCU or BPL from old ODAC version weren't removed (for example, if they were blocked by IDE on ODAC re-installation). We are glad that this issue was resolved. If any other questions come up, please contact me.