Detecting field aliases with quotes

How can I find out whether the fieldnames in a TOracleDataset were quoted in the actual select statement?

Example:
select artnr "Artikel_Nummer" from XXX order by YYY

We are working with a grid. Clicking on the grid title should change the order by clause by replacing YYY. But if I replace YYY with the column fieldname Artikel_Nummer Oracle will not allow this. I should have added the quotes around the name in the order by clause. Is there a simple way to find out from a TOracleDataset whether a certain field name should have quotes around it.
 
In this particular case you can order by the column index. Instead of trying to create this:

select artnr "Artikel_Nummer" from XXX
order by ARTNR

You can execute this:

select artnr "Artikel_Nummer" from XXX
order by 1

This makes your work a lot easier, since you can replace YYY by the grid column index (1-based).
 
That shouldn't be a problem, but it depends on the grid control. If the grid separates data column numbers and display column numbers, you can use the first. Otherwise you need to store the original column index somewhere to support column moving. Still a lot easier than parsing SQL.
 
The field index in the fields list of TOracleDataset is independent from the grid column index. The DBGrid component does not store the field index, but if I click on a column it should be easy to find the field index for the fieldname associated with the column.
 
Back
Top