TOraQuery and TOraSession

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
oppofix
Posts: 5
Joined: Tue 20 May 2008 12:56

TOraQuery and TOraSession

Post by oppofix » Tue 10 Jun 2008 13:11

Hi everybody,
I have a TOraSession inside a dataModule
called DM1.DataModule1.odacSession; in many functions
i need to realize some SELECT, using for this aim
some TOraQuery objects.
I don't want to create in the module DM1.DataModule1
many TOraQuery objects, above all because
i need to use them in many private functions,
so the objects would be too many.

But if i try to open a TOraQuery object in a function
implementation, the result is an error telling me
that there is a Write Memory Error.
I do as follows:

Function XYZ(...): integer;

var
odacQuery1: TOraQuery;

begin

odacQuery1.Session:= DM1.DataModule1.odacSession
...
...

end;

What am i doing wrong?
Thanks for any answers.
Fabrizio De Pietri

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 11 Jun 2008 07:13

You should call constructor of TOraQuery - Create before you use TOraQuery object, and you should call Free method after you finish work with TOraQuery object.

Code: Select all

Function XYZ(...): integer; 
var 
  odacQuery1: TOraQuery; 
begin 
  odacQuery1 := TOraQuery.Create(nil);
  try
    odacQuery1.Session:= DM1.DataModule1.odacSession 
    odacQuery1.SQL.Add('select 1 from dual');
    odacQuery1.Open;
    ...
    odacQuery1.Close;
  finally
    odacQuery1.Free;
  end;
end;

Post Reply