Order by queries against INSERT statements from procedures

  • From: Jose Manuel Quesada <jose.manuelquesada@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Fri, 10 Dec 2004 12:31:51 +0100

I have a temporary table filled with a statement like:
    INSERT INTO TEMP_TABLE
        SELECT A.ID, B.DATE_OPER, B.DATE_FIFO, B.AMOUNT T_AMOUNT
        FROM TABLE_A A, TABLE_B B
        WHERE A.ID = B.ID
        UNION ALL
        SELECT A.ID, C.DATE_OPER, C.DATE_FIFO, C.QUANTITY T_AMOUNT
        FROM TABLE_A A, TABLE_C C
        WHERE A.ID = C.ID;

I query the temporary table by means of an "order by" statement:
        SELECT * FROM TEMP_TABLE
        ORDER BY DATE_OPER, DATE_FIFO;

The issue is this:

1.- Every time I run the INSERT statement directly from SQL*PLUS, the
"order by" query returns always with the same sequence of ordered rows
sharing the same DATE_OPER, DATE_FIFO values.

2.- If I have the INSERT statement within a procedure, each time I run
the procedure, the "order by" query may return a different sequence of
ordered rows sharing the same DATE_OPER, DATE_FIFO values.

Any idea about this behaviour?
--
//www.freelists.org/webpage/oracle-l

Other related posts: