Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Altering the ORDER BY clause based on a parameter
On Mon, 19 Nov 2007 09:00:47 -0000, jeremy <jeremy0505_at_gmail.com>
wrote:
>In article <4740a498$0$19197$426a74cc_at_news.free.fr>, says...
>>
>> order by decode(p_order_by,1,date_col,2,name_col,3,desc_col...)
>>
>
>Hi Michel, this is what I thought but it runs into problems where the
>p_order_by param's data type differs from that of the column on which
>the order by is to be performed. Get runtime errors such as
>
>ERROR at line 1:
>ORA-01722: invalid number
>ORA-06512: at "WD.MYPROC", line 4
>ORA-06512: at line 1
>
>Any ideas?
>Also I would need to be able to specify the direction ASC or
>DESC of the query results.
Turn them all into text. For ASC/DESC convert them into numbers and multiply by +/-1 for ASC/DESC.
B.
>
>Dynamic SQL the way to go?
Received on Mon Nov 19 2007 - 09:02:06 CST
![]() |
![]() |