Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 86F182E0047 for ; Tue, 22 Apr 2008 07:12:05 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65078-10 for ; Tue, 22 Apr 2008 07:11:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by developer.postgresql.org (Postfix) with ESMTP id 88DB62E0046 for ; Tue, 22 Apr 2008 07:11:59 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JoFTc-0005Kz-Te for pgsql-sql@postgresql.org; Tue, 22 Apr 2008 10:11:52 +0000 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Apr 2008 10:11:52 +0000 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Apr 2008 10:11:52 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: Re: After updating dataset the record goes to the end of the dataset Date: Tue, 22 Apr 2008 12:11:42 +0200 Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.242 tagged_above=0 required=5 tests=AWL=-0.357, RCVD_IN_DNSWL_LOW=-1, RCVD_NUMERIC_HELO=2.599 X-Spam-Level: * X-Archive-Number: 200804/130 X-Sequence-Number: 30669 Nacef LABIDI, 22.04.2008 11:54: > Hi all, > > I am using Postgres in a Delphi application through ODBC. I am having an > issue with updating records. > > When I create a dataset to get the records in a table then after I > update one of these records and then refresh the dataset, the record > goes to the end of the dataset. This is disappointing when editing > records on a DBGrid, where users find their updated records jump to the > end of the grid. Even after restarting the application, the updated > record keeps showing at the end of the grid. I have tried the same thing > with SQL Server and it works normally, so I thought it was a postgres > behvior. > > Has anyone an idea about what could be the cause of such a behavior. Rows in a relational database are not sorted. This is true for any RDBMS. If you want to apply a certain sort order you *have* to use an ORDER BY clause for your SELECT. If the rows show up in the order you "expect" without an ORDER BY this is pure coincidence (even with SQL Server) The simply solution is to add an ORDER BY that sorts e.g. by a timestamp that is set when the row is created. Regards Thomas