What is t开发者_Go百科he best way to dynamically set the 'order by' column name and direction from parameters passed in to a plsql procedure?
You can use variables if you order using a case:
select *
from YourTable
order by
case when par_name = '1' then col1
when par_name = '2' then col2
end
, case when par_name = '3' then col3
end desc
use dynamic sql
http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96590/adg09dyn.htm
精彩评论