Re: Return serial from insert - Mailing list pgsql-novice

From Rod Kreisler
Subject Re: Return serial from insert
Date
Msg-id JNEGKNDJGBKLBDGPOPFOKEDPDEAA.rod@23net.net
Whole thread Raw
In response to Return serial from insert  (Rory Campbell-Lange <mail@campbell-lange.net>)
Responses Re: Return serial from insert
List pgsql-novice
You should get the nextval() from the sequence and use that for the new
insert and all related inserts.

> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Rory
> Campbell-Lange
> Sent: Friday, November 08, 2002 10:30 AM
> To: pgsql-novice@postgresql.org
> Subject: [NOVICE] Return serial from insert
>
>
> I would like to return the autoincremented serial number resulting from
> a new insert into a table, ideally as a result from the insert
> statement.
>
> Presumably this is the way to avoid race conditions between inserts into
> the database, because if I do 1) insert then 2) get max sequence val, 2
> might be wrong.
>
> Thanks
> Rory
>
> --
> Rory Campbell-Lange
> <rory@campbell-lange.net>
> <www.campbell-lange.net>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>


pgsql-novice by date:

Previous
From: Rory Campbell-Lange
Date:
Subject: Return serial from insert
Next
From: Rod Kreisler
Date:
Subject: Re: Return serial from insert