Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic Order By Clause

Re: Dynamic Order By Clause

From: Richard Kuhler <noone_at_nowhere.com>
Date: Wed, 21 Nov 2001 18:05:38 GMT
Message-ID: <S1SK7.41169$D5.18354279@typhoon.san.rr.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US