I need to run a SELECT statement where the column names are variable, as follows:
query.SQL.Text := 'SELECT A.:COLUMN '+
' FROM A ';
query.ParamByName('COLUMN').AsString := 'column_name';
query.Open();
But when I do this, there's an error in the SQL syntax because the component runs as:
SELECT A.'column_name'
FROM A
Is there a way to set these parameters without the quotes so I can dynamically choose columns?
You can change your query as follow (create subqueries with all columns). All columns that you select have to be the same type: