I am trying to refer to a column name to order a query in an application communicating with an Oracle database. I want to use a bind variable so that I can dynamically change what to order the query by.
The problem that I am having is that the database seems to be ignoring the order by column.
Does anyone know if there is a particular way to refer to a database column via a bind variable or if it is even possible?
e.g my query is SELECT * FROM PERSON ORDER BY :1 (where :1 will be bound to PERSON.NAME) The query is not returning results in alphabetical order, I am worried that the database is interpreting this as:- SELECT * FROM PERSON ORDER BY 'PERSON.NAME' which will obviously not work.
Any suggestions are much appreciated.