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 sql in PL/SQL

Re: dynamic sql in PL/SQL

From: Mike Cretan <nospamthanks_at_nowhere.com>
Date: Tue, 22 Mar 2005 22:28:03 GMT
Message-ID: <TZ00e.8018$C7.525@news-server.bigpond.net.au>

"Sybrand Bakker" <postbus_at_sybrandb.demon.nl> wrote in message news:do514155v501ur3p0f50oora25q02rtefe_at_4ax.com...
> On 22 Mar 2005 13:21:56 -0800, "jimmy gogo" <james.lawless_at_vhi.ie>
> wrote:
>
>>Do I have to use dynamic SQL here? What other options might I have?
>
> You have to use dynamic sql and you need to concatenate the order by
> clause (which is not a variable but a string) to the rest of the
> statement.
>
>
> --
> Sybrand Bakker, Senior Oracle DBA

Alternatively you could use a decode statement in your SQL statement for your order by -
e.g.
select *
  from emp
order by decode(:order_by_bind_variable,'NAME',ename,'ID',empno)

Mike Cretan, Senior Oracle Developer. Received on Tue Mar 22 2005 - 16:28:03 CST

Original text of this message

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