Subject | Re: [IBO] AssignSQLWithSearch don't accept parameters |
---|---|
Author | Helen Borrie |
Post date | 2010-01-21T09:00:51Z |
At 07:00 PM 21/01/2010, you wrote:
var
QIB: TIB_Query;
QIBO: TIBOQuery;
aValue: string; // or whatever it has to be
begin
try
QIB := TIB_Query.Create(self);
with QIB do
begin
IB_Connection := MyConnection;
IB_Transaction := MyTransaction;
SQL.Add ('SELECT * FROM TABLE1 WHERE FIELD1 = :P1');
IB_Transaction.StartTransaction;
Prepare;
end;
QIBO := TIBOQuery.Create(self);
with QIBO do
begin
IB_Connection := MyConnection;
IB_Transaction := MyTransaction;
end;
aValue := {whatever you are doing to get the param value};
QIB.ParamByName('P1').AsString := aValue;
with QIBO do
begin
AssignSQLWithSearch(QIB);
Open;
.... call your reporting procedure
end;
finally
QIBO.Close;
QIB.Close;
QIB.Free;
QIBO.Free;
end;
Helen
>Hi All.Assuming you already have an IB_Connection, MyConnection, and a TIB_Transaction, MyTransaction, with tiConcurrency isolation:
>
>I must pass the SQL of a TIB_Query to a TIBOQuery.
>
>AssignSQLWithSearch works only scanning the entire table: e.g.
>
>1) "SELECT * FROM TABLE1". Works.
>
>2) "SELECT * FROM TABLE1 WHERE ( FIELD1 = ?P1 )". ----> DON'T Works.
>
>the second case returns an empty query.
>
>This command seems to be useless, so I think there is a problem.
>How to pass the snapshot?
var
QIB: TIB_Query;
QIBO: TIBOQuery;
aValue: string; // or whatever it has to be
begin
try
QIB := TIB_Query.Create(self);
with QIB do
begin
IB_Connection := MyConnection;
IB_Transaction := MyTransaction;
SQL.Add ('SELECT * FROM TABLE1 WHERE FIELD1 = :P1');
IB_Transaction.StartTransaction;
Prepare;
end;
QIBO := TIBOQuery.Create(self);
with QIBO do
begin
IB_Connection := MyConnection;
IB_Transaction := MyTransaction;
end;
aValue := {whatever you are doing to get the param value};
QIB.ParamByName('P1').AsString := aValue;
with QIBO do
begin
AssignSQLWithSearch(QIB);
Open;
.... call your reporting procedure
end;
finally
QIBO.Close;
QIB.Close;
QIB.Free;
QIBO.Free;
end;
Helen