dbTalk Databases Forums  

reordering rows

comp.databases.postgresql comp.databases.postgresql


Discuss reordering rows in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
eldorado
 
Posts: n/a

Default reordering rows - 11-02-2006 , 02:15 PM






First let me say I am not a database expert, so I hope my question makes
sense. I apologize in advance if my question isn't worded completly
correct.

I am trying to prove a bug exists in a piece of code. I believe that the
code is reading and displaying information based on database order and not
a flag that is set in the database.

The table I am looking at has 64 fields. Each field has data. What I
would like to do is to take 2 rows and reverse the "natural" order. I
understand I can delete those rows and then re-insert them, but with the
amount of data it seems likely there could be human error. Is there
any other way to reorder rows already in the database?

Thanks in advance.

--
Randomly generated signature
I had an IQ test. The results came back negative.

Reply With Quote
  #2  
Old   
HansH
 
Posts: n/a

Default Re: reordering rows - 11-02-2006 , 03:18 PM






"eldorado" <eldorado (AT) io (DOT) com> schreef in bericht
news:20061102130524.D55425 (AT) eris (DOT) io.com...
Quote:
I am trying to prove a bug exists in a piece of code. I believe that the
code is reading and displaying information based on database order and not
a flag that is set in the database.

The table I am looking at has 64 fields.
I take it this is a single, physical table, NOT a join of a couple of
tables.
If the 64 fields are scattered across multiple tables proving your bug
require more details.

Quote:
Each field has data. What I would like to do is to take 2 rows and
reverse the "natural" order. I understand I can delete those rows and
then re-insert them, but with the amount of data it seems likely there
could be human error. Is there any other way to reorder rows already in
the database?
Rewriting a record is the only way, however that will happen even if you
change only a single field.
Thus, make a selection of just a few records and modify a field -add a
character to a varchar field- in the first row.
Redo the same selection and if you find the modified row listed last, you've
your bug proven.

If you use a frontend to view results be aware some may use an index to
order unsorted results. Such a frontend will mask the bug you are hunting
for.

Just a note of history: as of version 7.4 -released 2003-11-17- 'group by'
is often NOT doing 'order by' too.
http://www.postgresql.org/docs/8.1/s...lease-7-4.html


HansH




Reply With Quote
  #3  
Old   
eldorado
 
Posts: n/a

Default Re: reordering rows - 11-02-2006 , 03:45 PM



On Thu, 2 Nov 2006, HansH wrote:

Quote:
"eldorado" <eldorado (AT) io (DOT) com> schreef in bericht
news:20061102130524.D55425 (AT) eris (DOT) io.com...
I am trying to prove a bug exists in a piece of code. I believe that the
code is reading and displaying information based on database order and not
a flag that is set in the database.

The table I am looking at has 64 fields.
I take it this is a single, physical table, NOT a join of a couple of
tables.
If the 64 fields are scattered across multiple tables proving your bug
require more details.

Each field has data. What I would like to do is to take 2 rows and
reverse the "natural" order. I understand I can delete those rows and
then re-insert them, but with the amount of data it seems likely there
could be human error. Is there any other way to reorder rows already in
the database?
Rewriting a record is the only way, however that will happen even if you
change only a single field.
Thus, make a selection of just a few records and modify a field -add a
character to a varchar field- in the first row.
Redo the same selection and if you find the modified row listed last, you've
your bug proven.

If you use a frontend to view results be aware some may use an index to
order unsorted results. Such a frontend will mask the bug you are hunting
for.

Just a note of history: as of version 7.4 -released 2003-11-17- 'group by'
is often NOT doing 'order by' too.
http://www.postgresql.org/docs/8.1/s...lease-7-4.html
HansH
Thank you. This has given me more than enough to proceed.

--
Randomly generated signature
You do not need a parachute to skydive. You only need a parachute to skydive twice.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.