Re: order of rows when selecting from table of

  • From: "Ron Rogers" <RROGERS@xxxxxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 16 Apr 2004 08:31:35 -0400

Chupit,
Oracle being a wonderful and concerned corporation will only guarantee
that you will get the data out of the table when the select and other
clauses are correct.
Normally the data is returned in the order in which it is placed into
the table taking into consideration the fact that deletes and
sebsequentl inserts can occur. To insure that the data is returned in
the order you desire use the order by clause.
As an example:
Table AX has a date field. Each day data is inserted into the date
field. If data is deleted in the middle of the month and then later
re-inserted into the table the output from the select would not be in
date order unless the order by caluse is used.
Ron

>>> chupit@xxxxxx 04/16/2004 12:33:31 AM >>>
Hello oracle-l,

I have custom type that is "table of numbers", does Oracle guaranties
that when I use select from table(var) I will receive result in order
of indexes? If not, than how do I get not only the values but also
indexes of elements?

Thank you in advance!

Code snippet below:

SQL> create type num as table of integer
  2  /

Type created.

SQL> var result refcursor;
SQL> declare 
  2    n num := num();   
  3  begin
  4    n.extend(10);
  5    for i in 1 .. 10 loop
  6        n(i) := i;
  7    end loop;
  8    
  9    open :result for select column_value from table ( n );
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL> print result;

COLUMN_VALUE
------------
           1
           2
           3
           4
           5
           6
           7
           8
           9
          10

10 rows selected.

-- 
 Edgar        

----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com 
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx 
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/ 
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html 
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: