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: In Clause selecting in reverse order, wonder why?

Re: In Clause selecting in reverse order, wonder why?

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Mon, 7 Mar 2005 19:33:42 +0100
Message-ID: <422c9e45$0$9527$636a15ce@news.free.fr>

"Deepesh Garg" <deepesh.g_at_gmail.com> a écrit dans le message de news:398580b8.0503071009.21023d80_at_posting.google.com...
| Hi,
| I am running a query using an "in clause" in the condition. When no
| order clause is given, the query selects the rows in the reverse order
| in which the ids appears in the in clause.
| for example when I say select * from a_table where a_id in (1, 3, 9,
| 4);
| the rows are selected in the order where a_id is 4, 9, 3, 1.
| Tried with shuffling the ids and it always selects in the reverse
| order of whatever is provided.
| My query is:
| 1) Is it a standard behaviour? (of oracle, of sql)
| 2) Can I base my code upon this behaviour?
| Thanks,
| -Deepesh

  1. This is not sql. This is how RBO is coded: it takes the conditions from the last one to the first one (in list is converted to a set of or). With CBO you can add the ordered_predicates hint to force the order of evaluation of the predicates but this is not sure this hint is taken into account inside an "in".
  2. No as this behaviour can change.

Regards
Michel Cadot Received on Mon Mar 07 2005 - 12:33:42 CST

Original text of this message

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