Received: from ctb-mesg1.saix.net (ctb-mesg1.saix.net [196.25.240.73]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0A9V6B13139 for ; Wed, 10 Jan 2001 04:31:06 -0500 (EST) (envelope-from ahiggs@ps.co.za) Received: from phosphorous.ps (psw53-02-p87.ec.saix.net [155.239.165.87]) by ctb-mesg1.saix.net (8.11.1/8.11.1) with ESMTP id f0A9UHo07892 for ; Wed, 10 Jan 2001 11:30:17 +0200 (SAT) Received: from ps.co.za (andy [192.168.3.3]) by phosphorous.ps (8.10.2/8.10.2) with ESMTP id f0A9spj01456 for ; Wed, 10 Jan 2001 11:54:51 +0200 Message-ID: <3A5C2A94.8030408@ps.co.za> Date: Wed, 10 Jan 2001 11:25:40 +0200 From: Andrew Higgs User-Agent: Mozilla/5.0 (Windows; U; Win98; en-GB; m18) Gecko/20001106 Netscape6/6.0 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Using a rule as a trigger. Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/95 X-Sequence-Number: 756 Hi all, I have looked at some previous posting and thought that I had found exactly what I need. What I need is to insert an id (from a sequence) when a new record is inserted. The following example almost does what I need : CREATE TABLE topics (id int, topic varchar(50), descriotion text); CREATE SEQUENCE nextid start 1; CREATE RULE ins_topic AS ON INSERT TO topics WHERE id ISNULL DO UPDATE topics SET id=nextval('nextid') WHERE id ISNULL; This example updates the last insert. I need it to update the currnet insert. How do I do this? Kind regards Andrew Higgs