plsql - how to get this order by working in oracle pl/sql -


order case    when v_sort_type = 'asc'         case             when v_sort_order = 'lname' cast(lname varchar2(45)) || ',' || rownum            when v_sort_order = 'code' cast(code varchar2(52)) || ',' || rownum         end asc    when v_sort_type = 'dsc'         case             when v_sort_order = 'lname' cast(lname varchar2(45)) || ',' || rownum            when v_sort_order = 'code' cast(code varchar2(52)) || ',' || rownum         end desc                    end                    

i trying write conditions when v_sort_type passed in asc or dsc. getting compilation error in this.

i assume common thing in pl/sql sp's.

where going wrong?

you need rethink order multiple "columns".

order   case when v_sort_type = 'asc' , v_sort_order = 'lname' lname end asc,   case when v_sort_type = 'desc' , v_sort_order = 'lname' lname end desc,   case when v_sort_type = 'asc' , v_sort_order = 'code' cname end asc,   case when v_sort_type = 'desc' , v_sort_order = 'code' cname end desc 

only 1 of in effect @ 1 time, you'd (for example)

 order null asc,null desc,code asc, null desc 

or

 order null asc,lname desc,null asc, null desc 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -