<font size="-1"><font face="Helvetica, Arial, sans-serif">Nacef,<br /><br /> Simply add a SERIAL column to your table.
Whenyou add a new row, a new value will be stored in this column if you do not specify the column name in the insert
query.<br/> In your select query, always order by this column.<br /> When doing an update , do not update this column.
Whenre-ordering, update this column to indicate order. So if you want to move a row up, issue two update queries,
updatingthis column. Make sure you have some primary key in this table to uniquely identify these row.<br /><br />
Neverrely on the internal implementation of a database to keep the data in the order you insert/update.<br /><br />
Padam<br/></font></font><br /> Nacef LABIDI wrote: <blockquote
cite="mid:f16f7ea00804220331u226df1ean9a17e12d9324e078@mail.gmail.com"type="cite">You are right about the fact that the
rowsdon't keep the order they where created with at the start. I have verfied this.<br /><br /> I will explain more my
case:<br /><br /> I am writing an application where here is some resources to plan events on. I want to provide the
userwith the ability to customize the order in which resources are displayed on the screen. So there is a mapping
betweenthe rows positions in the dataset and they display positions. After updating one of these resources the row
jumpsto the end of the dataset so does the resource on the display. And the order gets scrambled. I cannot set this
orderin the databe since it is customizable for each user.<br /><br /> When I have tested this with SQLServer it works
well,since the rows doesn't change position on the DB.<br /><br /> I hope that you understand my issue and I will
provideany explanations if someting isn't clear enough.<br /><br /> Thanks to all<br /> Nacef<br /><br /><div
class="gmail_quote">OnTue, Apr 22, 2008 at 12:15 PM, hubert depesz lubaczewski <<a href="mailto:depesz@depesz.com"
moz-do-not-send="true">depesz@depesz.com</a>>wrote:<br /><blockquote class="gmail_quote" style="border-left: 1px
solidrgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Tue, Apr 22, 2008 at
12:10:41PM+0200, Nacef LABIDI wrote:<br /> > Yes I don't issue any sort statement, and I indeed want the data to be
show<br/> > as it is stored in the database. But after updating a row (I don't update<br /> > the ID, just some
fields),it keeps its same place on the DB but jumps to<br /> > the end of the dataset and by the way to the end of
theDBGrid.<br /><br /></div> why do you think it stays in the same place in db?<br /><br /> besides - without "order
by"you cannot depend on the order of rows.<br /> basically i treat them as in "random" order (which is not true, but<br
/>helps me remember to never count on the "default" ordering.<br /><br /> depesz<br /><font color="#888888"><br />
--<br/> quicksil1er: "postgres is excellent, but like any DB it requires a<br /> highly paid DBA. here's my CV!" :)<br
/><ahref="http://www.depesz.com/" moz-do-not-send="true" target="_blank">http://www.depesz.com/</a> - blog dla ciebie
(imoje CV)<br /></font></blockquote></div><br /></blockquote><br /><pre class="moz-signature" cols="72">--
PGP Id 9EED2E09</pre>