Subject Re: [ib-support] SQL add?
Author Artur Anjos
Daniel:

You can not use the Table Name as parameter. And I don't understand why you
set the parameters and next clear the query....

You should use something like this:

> begin
> with QRYT do
> begin
> Close; // Ok, you have close it because you will have a
different Query

> SQL.Clear; // Now, you set the SQL
> SQL.Add('SELECT * FROM ' + StrTable );
> SQL.Add('ORDER BY :NAME');
// Here, you really should prepare the query again...
// But, if you are using IBO you don't need to explicitly do it

> ParamByName('NAME').asstring := NAME;
> Open;
> end;
>

And this is not a IB/Firebird question, and you are off topic here. This is
a Delphi problem. You should post your message in some group that is related
to the components you are using (that you didn't not mention also...)

Artur

----- Original Message -----
From: "Daniel Bertin" <bertin@...>
To: <ib-support@yahoogroups.com>
Sent: Friday, April 05, 2002 9:42 PM
Subject: [ib-support] SQL add?


> Hi all,
> Why can I not execute this query? I get unknown table name error. but if I
> replace the params with the values it's ok. what am I missing?
>
> StrTable := 'ManuFact';
> NAME := 'MANNAME';
>
> begin
> with QRYT do
> begin
> Close;
> Parambyname('TABLE').asString := StrTable;
> ParamByName('NAME').asstring := NAME;
> SQL.Clear;
> SQL.Add('SELECT * FROM :TABLE');
> SQL.Add('ORDER BY :NAME');
> Open;
> end;
>
> Thanks
> Daniel