Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic Order By Clause
Well, besides using dynamic sql, you could do a decode...
select object_name, object_type
from all_objects
order by decode(columnname_in,
'OBJECT_NAME', object_name,
'OBJECT_TYPE', object_type)
Note: the dynamic sql method might be able to use an index for the ordering while the decode method cannot.
Richard
Prakash C N wrote:
>
> Hi,
>
> Can i have a dynamic order by clause, following is my example which
> is in a package
>
> select * from tab1
> order by columnname_in
>
> columnname_in will have the actual column name
> giving the flexibility of ordering by any column which is in tab1
> with out hardcoding the column name
>
> Thanks in advance
> -Regards
> Prakash C N
Received on Wed Nov 21 2001 - 12:05:38 CST
![]() |
![]() |