RE: [SQL] Getting primary key from insert statement

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: pgsql-sql(at)postgreSQL(dot)org
Subject: RE: [SQL] Getting primary key from insert statement
Date: 1999-06-08 08:26:37
Message-ID: l03130300b38282c0a844@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message José Soares 1999-06-08 13:15:20 Re: [SQL] Standard SQL commands - are they in 6.5?
Previous Message Chris Bitmead 1999-06-08 07:12:12 Re: [SQL] Slashdot Query