Using a rule as a trigger.

From: Andrew Higgs <ahiggs(at)ps(dot)co(dot)za>
To: pgsql-sql(at)postgresql(dot)org
Subject: Using a rule as a trigger.
Date: 2001-01-10 09:25:40
Message-ID: 3A5C2A94.8030408@ps.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tulio Oliveira 2001-01-10 14:24:29 Re: Using a rule as a trigger.
Previous Message Robert B. Easter 2001-01-09 22:21:03 MATCH