Subject | Very strange error in IBOQuery |
---|---|
Author | fowlertrainer |
Post date | 2005-02-22T08:41:33Z |
Hi !
I have an common interface, and I use it to hide database access.
I set query/db props in this interface.
See that code:
...
Qry.Close;
q:=Qry as TIBOQuery;
if SQL<>'' then begin
q.SQL.Clear;
q.SQL.Text:=SQL;
end;
q.IB_Connection:=DataBaseAsType;
q.IB_Transaction:=TransactionAsType;
if Assigned(TrObject) then q.IB_Transaction:=(TrObject as
TIBOTransaction);
...
if kva.Count>0 then begin
q.Unprepare;
if not q.Prepared // section 1
then q.Prepare;
end;
for i:=0 to kva.Count-1 do begin
s:=kva.Keys[i];
param:=q.Params.FindParam(s);
if Assigned(param) then begin
param.Value:=kva[s];
end;
end;
...
I set params from a dictionary.
The problem is that:
The section 1. is needed, because sometimes (if I not use this code)
the Params is not refreshed (count=0!!).
In this time I get strange error.
When I set SQL in this procedure, and call ExecSQL (params:
ID,TS_ID,WHEN), and set SQL to another SQL (params: ID), the IBOQuery
SQL parser is not drop previous ID param, it is use the previous value.
Previous: insert into ts (ID,TS_ID,WHEN) values (:ID,:TS_ID,:WHEN)
ID is string.
Actual: delete from ts where TS_ID=:id.
ID is integer.
But previous value is string, and now it have integer value.
The prepare raise exception (string->integer).
I try everything. I clear SQL. I clear params. I clear everything, but
the problem is living.
What I can do to prevent this ?
(Ok I can do an dummy RDB$DATABASE reading, but I don't want to do it.
I think that is clear the params).
Thanx for help:
ft
I have an common interface, and I use it to hide database access.
I set query/db props in this interface.
See that code:
...
Qry.Close;
q:=Qry as TIBOQuery;
if SQL<>'' then begin
q.SQL.Clear;
q.SQL.Text:=SQL;
end;
q.IB_Connection:=DataBaseAsType;
q.IB_Transaction:=TransactionAsType;
if Assigned(TrObject) then q.IB_Transaction:=(TrObject as
TIBOTransaction);
...
if kva.Count>0 then begin
q.Unprepare;
if not q.Prepared // section 1
then q.Prepare;
end;
for i:=0 to kva.Count-1 do begin
s:=kva.Keys[i];
param:=q.Params.FindParam(s);
if Assigned(param) then begin
param.Value:=kva[s];
end;
end;
...
I set params from a dictionary.
The problem is that:
The section 1. is needed, because sometimes (if I not use this code)
the Params is not refreshed (count=0!!).
In this time I get strange error.
When I set SQL in this procedure, and call ExecSQL (params:
ID,TS_ID,WHEN), and set SQL to another SQL (params: ID), the IBOQuery
SQL parser is not drop previous ID param, it is use the previous value.
Previous: insert into ts (ID,TS_ID,WHEN) values (:ID,:TS_ID,:WHEN)
ID is string.
Actual: delete from ts where TS_ID=:id.
ID is integer.
But previous value is string, and now it have integer value.
The prepare raise exception (string->integer).
I try everything. I clear SQL. I clear params. I clear everything, but
the problem is living.
What I can do to prevent this ?
(Ok I can do an dummy RDB$DATABASE reading, but I don't want to do it.
I think that is clear the params).
Thanx for help:
ft