Re: [SQL] Getting primary key from insert statement

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: emils(at)mail(dot)usis(dot)bkc(dot)lv, <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] Getting primary key from insert statement
Date: 1999-06-07 07:29:17
Message-ID: l03130300b3812492cf77@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Emils Klotins 1999-06-07 09:51:06 Re: [SQL] Getting primary key from insert statement
Previous Message Vikrant Rathore 1999-06-07 05:37:12 Re: [SQL] Mail about duplicate rows