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

Home -> Community -> Usenet -> c.d.o.misc -> Re: cursor :can you pass order-by as parameter?

Re: cursor :can you pass order-by as parameter?

From: Sybrand Bakker <gooiditweg_at_sybrandb.demon.nl>
Date: Wed, 31 Mar 2004 19:03:29 +0200
Message-ID: <lcul60l998hl34r8n7egs0cs4ml0134caj@4ax.com>


On Wed, 31 Mar 2004 16:03:40 GMT, mike <burnunit_at_DROPTHIS.hotmail.com> wrote:

>Hi, I'm relatively new to ORACLE forms - I hope this makes sense :-)
>
>Looking at : http://www.unix.org.ua/orelly/oracle/prog2/ch06_10.htm#SQL2-
>CH-6-SECT-10.2
>they state:
>
>"The most common place to use a parameter in a cursor is in the WHERE
>clause, but you can make reference to it anywhere in the SELECT
>statement, as shown here: "
>
>DECLARE
> CURSOR joke_cur (category_in VARCHAR2)
> IS
> SELECT name, category_in, last_used_date
> FROM joke
> WHERE category = UPPER (category_in);
>
>
>and this works fine. BUT if I want to dynamically order the results like
>this :
>
>DECLARE
> CURSOR joke_cur (category_in VARCHAR2, sort_key_in VARCHAR2)
> IS
> SELECT name, category_in, last_used_date
> FROM joke
> WHERE category = UPPER (category_in)
> ORDER BY sort_key_in;
>
>
>I would get back exactly the same results as the first example - the
>order by clause is ignored.
>
>Does anyone know how to dynamically specify the order by clause within a
>cursor?
>
>Thanks,
>
>Michael.

You will have to use dynamic sql, and probably end up with an unscalable application.
In Query mode in Forms it used to be possible to hit the & key to specify extra conditions.

--
Sybrand Bakker, Senior Oracle DBA
Received on Wed Mar 31 2004 - 11:03:29 CST

Original text of this message

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