From: Bruno Wolff III <bruno@wolff.to>
To: MaurĂcio Sessue Otta <mauricio@cristorei.com.br>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting sequence value after inserting many rows at a time
Date: Thu, 9 Jan 2003 19:25:15 -0600
Message-ID: <20030110012515.GA22248@wolff.to> (raw)
In-Reply-To: <010901c2b841$f429f290$830101c0@mauricio1>
References: <010901c2b841$f429f290$830101c0@mauricio1>
On Thu, Jan 09, 2003 at 22:48:11 -0200,
MaurĂcio Sessue Otta <mauricio@cristorei.com.br> wrote:
> Hi,
>
> I have a PHP script that do something like this:
>
> INSERT INTO table_with_sequence (field1, field2...., fieldn)
> SELECT field1, field2, ..., fieldn FROM table,table
> WHERE condition, condition
>
> My doubt:
> Will the rows just inserted in "table_with_sequence" always be sequencial?
> (won't it happen to have X rows from this INSERT, 1 rows from another INSERT
> in the middle and the rest rows of the first INSERT?)
>
> How can I safely get the first value the INSERT "generated" for
> the sequence?
You might want to reconsider the design. You might want to use another
serial column to indicate the grouping. This will allow you to pick out
records inserted as a group.
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: bruno@wolff.to, mauricio@cristorei.com.br
Subject: Re: Getting sequence value after inserting many rows at a time
In-Reply-To: <20030110012515.GA22248@wolff.to>
* 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