Tablename as parameter
Posted: 13.07.2006, 11:44
Is it possible to submit the name of the table for a query as a parameter? I am using a query that is combined several times with union, so i would have to change several times the query.
The original query looks like this (only an example, the original is more complex)
Select Name
by l06_parameter
where ...
UNION
Select Name
by l06_parameter
where ...
...
this works perfect. So i tried to make it this way:
Select Name
by :LTABLE
where ...
UNION
Select Name
by :LTABLE
where ...
.ParamByName(':LTABLE').asstring:=l06_parameter;
If i open now the query, i get an error like this:
SQL Error: You have an error in your SQL syntax; check the manual that correspond to your MySQL server version for the right syntax to use near ''l06_parameterdaten' where ...' at line 1.
The problem is, that with the parameter i get quote-signals around the name.
But i don't find any solution for the problem.
Thanks for every answer
Chaosworld
PS: If this question is wrong here, could anybody move it to the correct place, i am not sure where is the best place.
The original query looks like this (only an example, the original is more complex)
Select Name
by l06_parameter
where ...
UNION
Select Name
by l06_parameter
where ...
...
this works perfect. So i tried to make it this way:
Select Name
by :LTABLE
where ...
UNION
Select Name
by :LTABLE
where ...
.ParamByName(':LTABLE').asstring:=l06_parameter;
If i open now the query, i get an error like this:
SQL Error: You have an error in your SQL syntax; check the manual that correspond to your MySQL server version for the right syntax to use near ''l06_parameterdaten' where ...' at line 1.
The problem is, that with the parameter i get quote-signals around the name.
But i don't find any solution for the problem.
Thanks for every answer
Chaosworld
PS: If this question is wrong here, could anybody move it to the correct place, i am not sure where is the best place.