From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Getting primary key from insert statement
Date: Tue, 8 Jun 1999 11:26:37 +0300
Message-ID: <l03130300b38282c0a844@[147.233.159.109]> (raw)
In-Reply-To: <93C04F1F5173D211A27900105AA8FCFC14557B@lambic.prevuenet.com>
At 23:10 +0300 on 07/06/1999, Michael J Davis wrote:
> I have been using this technique for years in Oracle (select next value from
> the primary key sequence and insert using this primary key). I like this
> approach. I don't think a transaction is needed.
I don't know what mechanism Oracle uses. Perhaps even a transaction is not
needed (although logically, the two operations should be one, so as not to
allow the failure of the insertion, if only to save on unused key values).
But doing things like that on the client side means that there is no
logical connection between the sequence and the table. Anybody is free to
enter any primary key, and a mistake in one of the front ends will cause
inconsistency in the database. The theory of databases asserts that you
should try to insert the logic and constraints of the organization's data
into the backend.
I know that this should mean that in fields declared "serial", values other
than the default should not be allowed. Perhaps this should be addressed in
new versions of Postgres somewhere.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
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: <l03130300b38282c0a844@[147.233.159.109]>
References: <93C04F1F5173D211A27900105AA8FCFC14557B@lambic.prevuenet.com> <l03130300b38282c0a844@[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