Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id D7CAB2E02D0 for ; Mon, 17 Dec 2007 15:26:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 09631-04 for ; Mon, 17 Dec 2007 15:25:59 -0400 (AST) Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.187]) by postgresql.org (Postfix) with ESMTP id E56652E022A for ; Mon, 17 Dec 2007 15:26:08 -0400 (AST) Received: by mu-out-0910.google.com with SMTP id i10so3501662mue.3 for ; Mon, 17 Dec 2007 11:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; bh=y1ez5yIoS0l9IYnYEiWmGCXj2tpUi6DCf59nfuVeaxI=; b=OMYySDBQXap6iWlIdWbL2UxjH5sUVSGjFRNQYQVnVdfxRsbyD3emsMmaPM5VCA7wkb14pbbBlVQYXFtvmSjIsfovZxne66VBPydPSKWip/HkAhZlILzpSSXtRkhhtRJjpFRGExvuZqOZvHzDmvcb1j+X9/V2lv7lma+9oDwD5JM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=xIZ2RAiutjWF9InV0mUiigV8Pgv8/Ig3U8XFSMQA+szQOVctHVsL73J6PP6hHin1SDhK8zlSAOxa3r6RvAIP8pEC+9owjoT3rKnClzdktFbX9LD4s8b3xZl/ccyGA0ALVbVyH3u8f5Lv9Q5qEOLOguPvsYXhpBpejexnIklyHXs= Received: by 10.86.4.2 with SMTP id 2mr6764627fgd.41.1197919566648; Mon, 17 Dec 2007 11:26:06 -0800 (PST) Received: from ?192.168.1.2? ( [83.187.228.250]) by mx.google.com with ESMTPS id 12sm6073950fgg.2007.12.17.11.26.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 17 Dec 2007 11:26:06 -0800 (PST) Message-ID: <4766CE38.6060904@gmail.com> Date: Mon, 17 Dec 2007 20:30:00 +0100 From: Luigi Pirillo User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Insert into and Sequence Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/96 X-Sequence-Number: 29788 Hi to all, executing an INSERT INTO like this: INSERT INTO "_Tests_Steps" ( "New_Test_Step_Id", "Test_Step_Id", "Process_Test_Id", "Step_Id", "Sequence_Id", "StepGroup_Id", "Skip" ) SELECT nextval('"Tests_Steps_Test_Step_Id_seq"'), "Test_Step_Id", B."Process_Test_Id", "Step_Id", "Sequence_Id", "StepGroup_Id", A."Skip" FROM "_Processes_Tests" B INNER JOIN "Tests_Steps" A ON A."Process_Test_Id" = B."Process_Test_Id" WHERE "Version_Id" = vers_id ORDER BY "Test_Step_Id"; ............... where "_Tests_Steps" and "_Processes_Tests" are both temporary tables, in the resulting "_Tests_Steps table records are not sorted in the expected mode. In other word, I need to extract records from "Tests_Steps" and then put them in "_Tests_Steps" ordered exactly as they were inserted first time. This because I need to duplicate this records, assigning them a new serial value. This records are later binding to others records of different tables. The resulting recordset is the follow: "New_Test_Step_Id", "Test_Step_Id", "Process_Test_Id", "Step_Id", "Sequence_Id", "StepGroup_Id", "Skip" 2332; 2136; 2225; 958; 404; 363; f 2331; 2137; 2225; 959; 404; 363; f 2334; 2285; 2225; 960; 404; 363; f 2333; 2286; 2225; 961; 404; 363; f Apparently, new records are not inserted in the table according to the order selected by "Test_Step_Id" field; Any suggest?? Thanks in advance Luigi Pirillo