开发者

Setting the 'Order By' Clause from plsql procedure parameters

开发者 https://www.devze.com 2023-01-13 18:56 出处:网络
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:

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

精彩评论

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