pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Michael J Davis <michael.j.davis@tvguide.com>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Getting primary key from insert statement
Date: Tue, 8 Jun 1999 19:40:17 +0300
Message-ID: <l03130302b382f5c2b12e@[147.233.159.109]> (raw)
In-Reply-To: <93C04F1F5173D211A27900105AA8FCFC14558A@lambic.prevuenet.com>

At 19:23 +0300 on 08/06/1999, Michael J Davis wrote:


> I accomplish this by trapping the "Before Insert" event in the form used to
> add new Status records (the user is NOT entering the StatusID) and doing the
> following:
>
> 	Form.StatusID = getSeqValue('Status_seq')

Thus, you do it in the frontend. Six months later, a programmer writes
another form that accesses the same table, and fails to do so, or leaves it
to the user. Or he decides that he has a better number generator to use.
There are errors. Perhaps his form generates numbers which the sequence has
not yet reached. Conflicts ocuur. Boss unhappy.

That happens because you failed to centralize the logic of your database.

As I said, the "serial" datatype is not a complete fail-safe, because it
still allows entering non-sequence values. But at least it's a step in the
right direction. Putting the logic in the client side is the wrong thing to
do.

To finish in a humorous note, I wouldn't use programming practices
encouraged by Microsoft products as pillars of truth...

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: <l03130302b382f5c2b12e@[147.233.159.109]>
Permalink:  ../l03130302b382f5c2b12e@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b382f5c2b12e@[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, michael.j.davis@tvguide.com
  Subject: Re: [SQL] Getting primary key from insert statement
  In-Reply-To: <l03130302b382f5c2b12e@[147.233.159.109]>
  References: <93C04F1F5173D211A27900105AA8FCFC14558A@lambic.prevuenet.com> <l03130302b382f5c2b12e@[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