Re: Insert Order into a table

From: Jim Kennedy <kennedy-down_with_spammers_at_no_spam.comcast.net>
Date: Sat, 06 Sep 2003 02:20:20 GMT
Message-ID: <Evb6b.368968$YN5.247996_at_sccrnsc01>


"traceable1" <traceable1_at_hotmail.com> wrote in message news:8551d8c9.0309051255.2a56c9b0_at_posting.google.com...
> I am inserting data rows into a table via a stored procedure. After
> the inserts, I query the rows in the table and I want them to spit
> back out in the same order I put them in.
>
> However, apparently, Oracle actually inserts the rows in some type of
> bulk insert, so they are not in the same order I put them in. I run a
> COMMIT after each insert, to no avail.
>
> Here's kind of an example of what I'm talking about:
>
> INSERT into mytable ('A'); COMMIT;
> INSERT into mytable ('B'); COMMIT;
> INSERT into mytable ('C'); COMMIT;
> INSERT into mytable ('D'); COMMIT;
>
> SELECT * FROM mytable;
>
> B
> C
> A
> D
>
>
> How can I force Oracle to put these rows in the table correctly?
> (and, probably, less efficiently, but I don't care).
>
> I realize this table needs some sort of KEY column, but that is not an
> option at this point.
>
> Thanks in advance to anyone who can help!!
>
> traceable

You should ask for the data in the order you want it. doing a commit after each statement is going to slow things down.(and doesn't have anything to do with what you aretrying to accomplish). The problem is that you fail to grasp that sql (structured query language) is a set based language and how the data is stored in the table is irrelevant to the order you put it in. You need to specify the order of the data in the set you ask for and sql will return it in that order. eg select * from mytable order by 1;

for more information read up on Codd and get a better understanding. We are not dealing with a file based system but a RDBMS. Jim Received on Sat Sep 06 2003 - 04:20:20 CEST

Original text of this message