From: Luigi Pirillo <luigi.pirillo@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Insert into and Sequence
Date: Mon, 17 Dec 2007 20:30:00 +0100
Message-ID: <4766CE38.6060904@gmail.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: luigi.pirillo@gmail.com
Subject: Re: Insert into and Sequence
In-Reply-To: <4766CE38.6060904@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox