Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA01885 for ; Tue, 8 Jun 1999 12:39:35 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 0F8F14B510; Tue, 8 Jun 1999 19:39:25 +0300 (IDT) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA4D9F; Tue, 8 Jun 1999 19:42:01 +0300 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <93C04F1F5173D211A27900105AA8FCFC14558A@lambic.prevuenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 8 Jun 1999 19:40:17 +0300 To: Michael J Davis , pgsql-sql@postgreSQL.org From: Herouth Maoz Subject: RE: [SQL] Getting primary key from insert statement 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