Prepared Statment - Order by
Language : Java
Database : Oracle
I am trying to use the following sql
select * from EMPLOYEE WHERE EMPLOYEE_LASTNAME='ABC'
ORDER BY EMPLOYEE_LASTNAME
using prepared statment :
select * from EMPLOYEE WHERE EMPLOYEE_LASTNAME=?
ORDER BY ?
I set the parameters using
pstmt.setString(1,'ABC');
pstmt.setString(2,'EMPLOYEE_LASTNAME'); (instead of this I could also use
pstmt.setInt(2,1) -- but this also does not sort the results)
After I execute the prepared statment I get the correct results but they are not Sorted i.e the ORDER BY clause does not work ?
Has anyone come across this problem before ? Can anyone provide any solutions ?
Thanks in advance,
Ann.

