Hello,
I'm working with DOA 4.1.2 in Delphi 2009 with Oracle 10gR2 (10.2.0.1.0) or Oracle 11gR2 (11.2.0.1).
In order to not block my application, when I open a huge dataset, I'll do the TOracleDataSet.open in a thread:
- Main thread start another thread
- Main thread wait the end of this thread
- the thread open the dataset and display data in a dbgrid
In Oracle 10.2.0.1.0, when I execute the open everything works perfectly.
In Oracle 11.2.0.1.0, sometimes there is external exception: External exception EBADBB81. When I remove the thread, TOracleDataSet.open works perfectly.
So my questions are:
1- why there are errors in Oracle 11.2.0.1.0 and not in 10.2.0.1.0?
2- If I set ThreadSafe property to True, there is no problem, why should I use this property in Oracle 11g but not in Oracle 10g?
3- If I have Oracle instructions (open on a TOracleDataset by example) in a timer, should I set ThreadSafe property to True?
4- What are the impacts (performance, use) in relation to setting ThreadSafe property to true?
Here is the function I use to execute the TOracleDataSet.open and wait for the end:
unit UExecWithProcMsg;
interface
uses Windows, SysUtils, Classes;
const atl = 'atl.dll';
type
TAtlWaitWithMessageLoop = function(h: THandle): Boolean; stdcall;
TExecFunc = procedure() of object;
TAppliThread = class(TThread)
protected
func: TExecFunc;
procedure Execute; override;
public
constructor Create(func: TExecFunc);
end;
TExecWithProcMsg = class
private
init: Boolean;
HInst: THandle;
FPointer: TFarProc;
altWaitMsgLoop: TAtlWaitWithMessageLoop;
appliTh: TAppliThread;
procedure Initialize();
procedure Finalize();
public
constructor Create();
procedure Exec(func: TExecFunc);
procedure WaitWithMessageLoop(thread: THandle);
end;
implementation
constructor TExecWithProcMsg.Create();
begin
init := false;
inherited Create;
end;
procedure TExecWithProcMsg.Initialize();
begin
HInst := LoadLibrary(atl);
if HInst > 0 then
try
FPointer := GetProcAddress(HInst, PChar('AtlWaitWithMessageLoop'));
if FPointer nil then
begin
altWaitMsgLoop := TAtlWaitWithMessageLoop(FPointer);
end;
except
on E: Exception do
begin
init := false;
raise;
end;
end;
init := true;
end;
procedure TExecWithProcMsg.WaitWithMessageLoop(thread: THandle);
begin
if not init then
begin
try
Initialize;
except
end;
end;
if init then
altWaitMsgLoop(thread)
else // s'il y a un probl
I'm working with DOA 4.1.2 in Delphi 2009 with Oracle 10gR2 (10.2.0.1.0) or Oracle 11gR2 (11.2.0.1).
In order to not block my application, when I open a huge dataset, I'll do the TOracleDataSet.open in a thread:
- Main thread start another thread
- Main thread wait the end of this thread
- the thread open the dataset and display data in a dbgrid
In Oracle 10.2.0.1.0, when I execute the open everything works perfectly.
In Oracle 11.2.0.1.0, sometimes there is external exception: External exception EBADBB81. When I remove the thread, TOracleDataSet.open works perfectly.
So my questions are:
1- why there are errors in Oracle 11.2.0.1.0 and not in 10.2.0.1.0?
2- If I set ThreadSafe property to True, there is no problem, why should I use this property in Oracle 11g but not in Oracle 10g?
3- If I have Oracle instructions (open on a TOracleDataset by example) in a timer, should I set ThreadSafe property to True?
4- What are the impacts (performance, use) in relation to setting ThreadSafe property to true?
Here is the function I use to execute the TOracleDataSet.open and wait for the end:
unit UExecWithProcMsg;
interface
uses Windows, SysUtils, Classes;
const atl = 'atl.dll';
type
TAtlWaitWithMessageLoop = function(h: THandle): Boolean; stdcall;
TExecFunc = procedure() of object;
TAppliThread = class(TThread)
protected
func: TExecFunc;
procedure Execute; override;
public
constructor Create(func: TExecFunc);
end;
TExecWithProcMsg = class
private
init: Boolean;
HInst: THandle;
FPointer: TFarProc;
altWaitMsgLoop: TAtlWaitWithMessageLoop;
appliTh: TAppliThread;
procedure Initialize();
procedure Finalize();
public
constructor Create();
procedure Exec(func: TExecFunc);
procedure WaitWithMessageLoop(thread: THandle);
end;
implementation
constructor TExecWithProcMsg.Create();
begin
init := false;
inherited Create;
end;
procedure TExecWithProcMsg.Initialize();
begin
HInst := LoadLibrary(atl);
if HInst > 0 then
try
FPointer := GetProcAddress(HInst, PChar('AtlWaitWithMessageLoop'));
if FPointer nil then
begin
altWaitMsgLoop := TAtlWaitWithMessageLoop(FPointer);
end;
except
on E: Exception do
begin
init := false;
raise;
end;
end;
init := true;
end;
procedure TExecWithProcMsg.WaitWithMessageLoop(thread: THandle);
begin
if not init then
begin
try
Initialize;
except
end;
end;
if init then
altWaitMsgLoop(thread)
else // s'il y a un probl