Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic Order By Clause
create table T1(ID number, C1 varchar2, C2 date);
You can try something similar:
select ID,C1,C2,
decode(:P_SORTING,
'ID',to_char(ID,'00000000000000.0000000000000000'), 'C1',C1, 'C2',to_char(C2,'YYYYMMDDHH24MISS'), '')
But IMHO the best way is using of dynamic (DBMS_SQL package) or native (EXECUTE IMMEDIATE) SQL for such tasks.
"Prakash C N" <prakashcn_at_hotmail.com> wrote in message
news:7e1c2f8c.0111210812.416e524f_at_posting.google.com...
> 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:31:25 CST
![]() |
![]() |