pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: emils@mail.usis.bkc.lv, <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Getting primary key from insert statement
Date: Mon, 7 Jun 1999 10:29:17 +0300
Message-ID: <l03130300b3812492cf77@[147.233.159.109]> (raw)
In-Reply-To: <199906070647.JAA08463@omega.bkc.lv>
References: <l03130304b38014d3b9f7@[147.233.159.109]>
	<551413BBBB03D111BF880060B01AACCE0B38FA@home.priority.net>

At 12:51 +0300 on 07/06/1999, Emils Klotins wrote:


>
> Wouldn't it be simpler just to SELECT the next value from the sequence
>BEFORE the insert and
> use it in the INSERT statement directly?

Then you have to have a transaction around the two operations. And by the
time you do the select, someone may lock the table where you insert. It's a
potential for deadlock.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (14+ messages)  latest in thread

Message-ID: <l03130300b3812492cf77@[147.233.159.109]>
Permalink:  ../l03130300b3812492cf77@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130300b3812492cf77@[147.233.159.109]

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il
  Subject: Re: [SQL] Getting primary key from insert statement
  In-Reply-To: <l03130300b3812492cf77@[147.233.159.109]>
  References: <l03130304b38014d3b9f7@[147.233.159.109]> <551413BBBB03D111BF880060B01AACCE0B38FA@home.priority.net> <l03130300b3812492cf77@[147.233.159.109]>

* 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