Using dynamic sql. Igor Neyman, OCP DBA ineyman@xxxxxxxxxxxxxx -----Original Message----- From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of geraldine_2@xxxxxxxxxxx Sent: Tuesday, March 22, 2005 3:16 PM To: oracle-l@xxxxxxxxxxxxx Subject: using variable name in order by Hi, Is there a limitation whereby I can't substitute the variable (varname) with literal string such such name or sal in the ORDER BY clause below? I can use variable in the WHERE clause but not in the ORDER BY. OPEN emprefcursor FOR select name from emp where sal>10000 order by varname; Based on certain conditions, the varname can be name or sal. However, for some reasons, when I ran the procedure, it failed to replace the varname. Any other alternatives to accomplish the same thing? Thanks. Geraldine -- //www.freelists.org/webpage/oracle-l -- //www.freelists.org/webpage/oracle-l