From: Tulio Oliveira <mestredosmagos@marilia.com>
To: Andrew Higgs <ahiggs@ps.co.za>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using a rule as a trigger.
Date: Wed, 10 Jan 2001 12:24:29 -0200
Message-ID: <3A5C709D.8438F2FE@marilia.com> (raw)
References: <3A5C2A94.8030408@ps.co.za>
Andrew Higgs wrote:
>
> 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
Isn't better create the field "id" as "serial" instead "int" ???
this will do what you need.
--
======================================================
AKACIA TECNOLOGIA
Desenvolvimento de sistemas para Internet
www.akacia.com.br
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: mestredosmagos@marilia.com, ahiggs@ps.co.za
Subject: Re: Using a rule as a trigger.
In-Reply-To: <3A5C709D.8438F2FE@marilia.com>
References: <3A5C2A94.8030408@ps.co.za> <3A5C709D.8438F2FE@marilia.com>
* 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