Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 147052E011A for ; Wed, 19 Dec 2007 09:21:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50807-02 for ; Wed, 19 Dec 2007 09:21:39 -0400 (AST) Received: from mx1.wp.pl (mx1.wp.pl [212.77.101.5]) by postgresql.org (Postfix) with ESMTP id 2E5D22E338E for ; Wed, 19 Dec 2007 09:21:38 -0400 (AST) Received: (wp-smtpd smtp.wp.pl 4757 invoked from network); 19 Dec 2007 14:21:36 +0100 Received: from ip-213-17-164-70.netia.com.pl (HELO [127.0.0.1]) (ipluta@[213.17.164.70]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with SMTP for ; 19 Dec 2007 14:21:36 +0100 Message-ID: <47691AD9.5070704@wp.pl> Date: Wed, 19 Dec 2007 14:21:29 +0100 From: Ireneusz Pluta User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Luigi Pirillo CC: pgsql-sql@postgresql.org Subject: Re: Insert into and Sequence References: <4766CE38.6060904@gmail.com> In-Reply-To: <4766CE38.6060904@gmail.com> Content-Type: text/html; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [ARMk] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/102 X-Sequence-Number: 29794

Apparently, new records are not inserted in the table according to the order selected by "Test_Step_Id" field;
As seen in: http://en.wikipedia.org/wiki/SQL:
"The order of rows returned by an SQL query is never guaranteed unless an ORDER BY clause is specified".

In other words, a database system does not guarantee you the order in which table rows are stored. So, the order in which you insert your rows is not the one which has to be followed when selecting them afterwards. You must specify by "ORDER BY" how you want to sort your recordset.

It seems you need to revisit the concept of your system.

Best regards

Irek