pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Higgs <ahiggs@ps.co.za>
To: pgsql-sql@postgresql.org
Subject: Using a rule as a trigger.
Date: Wed, 10 Jan 2001 11:25:40 +0200
Message-ID: <3A5C2A94.8030408@ps.co.za> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <3A5C2A94.8030408@ps.co.za>
Permalink:  ../3A5C2A94.8030408@ps.co.za/
Also on:    postgresql.org/message-id/3A5C2A94.8030408@ps.co.za

 · 

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: ahiggs@ps.co.za
  Subject: Re: Using a rule as a trigger.
  In-Reply-To: <3A5C2A94.8030408@ps.co.za>
  References: <3A5C2A94.8030408@ps.co.za>

* 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