Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Row sort order in table with no index

Status
Not open for further replies.

jrtex

Programmer
Dec 7, 2000
11
US
We have a temp table that we are storing some info that will then be processed thru another program(Crystal reports). When we are loading records into the table we have already sorted the data based on certain criteria. As we read thru the recordset to populate the table, the data is being read in the order we would expect but when we view the table before the print runs the order looks to be some sort of default sort order.

Example: I have 3 accounts, 1, 2, 3 that have 3 payments made to them but account 3 was paid first(control number 1), 1 was next then 2. The recordset created shows the order as being 3,1,2. When we start the insert into the temp table account 3 is inserted first. Then account 1, then 2. The issue is that when number 1 is entered it is put before number 3 in the table. When number 2 is entered it is put between 1 & 3.

So, simply, is their a default sort that is created within Oracle for a table? Is there a way to stop what is happening without putting an index on the table?

Thanks. JR
 
You really need to get out of your head all these ideas of "order" in a relational database. There is no such thing. The order of insert is not necessarily the order the data will be stored, and the order it is retrieved can vary unpredictably with every select statement.

The only safe thing to do is to use an "order by" clause with every select statement. In your case it appears that you want to report on the accounts in the order that payments were made. That implies that you should have a "payment_date" column in your table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top