Subject | Re: [IBO] Delphi-Ibo spesific question... |
---|---|
Author | Salvatore Besso |
Post date | 2004-04-14T09:36:46Z |
hello Burak,
sometimes you could try to release a non allocated query. What about
moving the Trim test outside the "try-finally" block since in this
case you don't need the query? Moreover, use FreeAndNil to release
your objects:
function
TDataMod.Get_Doviz_Kur(PRM_DOVKOD:String;PRM_TARIH:TDateTime;PRM_TIP:B
yte;PRM_ISN:Integer):Currency;
var qryDOVKUR:TIB_Query;
Msg : PChar;
begin
if Trim(PRM_DOVKOD) = glb_DEFCUR then
begin
Result := 1;
Exit;
end;
try
try
DataMod.CreateQuery(qryDOVKUR,nil,False,True);
DO SMTHING XXXXXXXXXXXXXXXXXXXXXXXXXXxxx
except
Application.MessageBox(MSG,'Dikkat',MB_ICONERROR);
Result := 0;
raise;
end;
finally
DataMod.ReleaseQuery(qryDOVKUR);
end;
end;
procedure TDataMod.CreateQuery(Var
Query:TIB_Query;Transaction:TIB_Transaction;RequestLive,ReadOnly:Boole
an);
begin
Query := TIB_Query.Create(Self);
Query.IB_Connection := DataMod.dbaMain;
if Transaction <> Nil then Query.IB_Transaction := Transaction;
Query.RequestLive := RequestLive;
Query.ReadOnly := ReadOnly;
end;
procedure TDataMod.ReleaseQuery(var Query:TIB_Query);
begin
if Assigned(Query) then
begin
if Query.Active then
Query.Close;
FreeAndNil(Query);
end;
end;
Best regards
Salvatore
> if Trim(PRM_DOVKOD) = glb_DEFCUR then if theI'm not sure to have understood what you want, but it seems that
> equality accures qryDOVKUR.Create never runs,
> but the object is on the memory.
sometimes you could try to release a non allocated query. What about
moving the Trim test outside the "try-finally" block since in this
case you don't need the query? Moreover, use FreeAndNil to release
your objects:
function
TDataMod.Get_Doviz_Kur(PRM_DOVKOD:String;PRM_TARIH:TDateTime;PRM_TIP:B
yte;PRM_ISN:Integer):Currency;
var qryDOVKUR:TIB_Query;
Msg : PChar;
begin
if Trim(PRM_DOVKOD) = glb_DEFCUR then
begin
Result := 1;
Exit;
end;
try
try
DataMod.CreateQuery(qryDOVKUR,nil,False,True);
DO SMTHING XXXXXXXXXXXXXXXXXXXXXXXXXXxxx
except
Application.MessageBox(MSG,'Dikkat',MB_ICONERROR);
Result := 0;
raise;
end;
finally
DataMod.ReleaseQuery(qryDOVKUR);
end;
end;
procedure TDataMod.CreateQuery(Var
Query:TIB_Query;Transaction:TIB_Transaction;RequestLive,ReadOnly:Boole
an);
begin
Query := TIB_Query.Create(Self);
Query.IB_Connection := DataMod.dbaMain;
if Transaction <> Nil then Query.IB_Transaction := Transaction;
Query.RequestLive := RequestLive;
Query.ReadOnly := ReadOnly;
end;
procedure TDataMod.ReleaseQuery(var Query:TIB_Query);
begin
if Assigned(Query) then
begin
if Query.Active then
Query.Close;
FreeAndNil(Query);
end;
end;
Best regards
Salvatore