开发者

Setting the 'Order By' Clause from plsql procedure parameters

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜