pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Albert REINER <areiner@tph.tuwien.ac.at>
To: pgsql-sql@postgresql.org
Subject: Re: how to create this trigger?
Date: Fri, 2 Feb 2001 00:08:41 +0100
Message-ID: <20010202000841.A1197@frithjof> (raw)
In-Reply-To: <KJEFJKLOGBDOOKFDDKKLMEMGCCAA.ramiroa@coordinadora.com.co>
References: <KJEFJKLOGBDOOKFDDKKLMEMGCCAA.ramiroa@coordinadora.com.co>

Don't know much, but couldn't you let increment_value take an argument
and run it on new.code?

But maybe I am completely off.

Albert.


On Thu, Feb 01, 2001 at 04:48:28PM -0500, Ramiro Arenas Ramírez wrote:
> I need to create a trigger that increment a value in a column 
> of table1 where a row is inserted in table 2
> 
> I have tried whit this but it just does nothing.
> 
> CREATE FUNCTION increment_value () RETURNS opaque AS 
> 'DECLARE
>    code int4;
>    BEGIN
>    code := new.code;
>    UPDATE table1 
>    SET value = value + 1
>    WHERE id = code;
> RETURN NEW;
> END;'  LANGUAGE 'plpgsql';
> 
> CREATE TRIGGER insert_on_table2 BEFORE INSERT ON table2 
> 	FOR EACH ROW EXECUTE PROCEDURE increment_value();
> 
> 
> Can you help me? 
> 
> 
> 
> 

-- 

--------------------------------------------------------------------------
Albert Reiner                                   <areiner@tph.tuwien.ac.at>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------



view thread (3+ messages)

Message-ID: <20010202000841.A1197@frithjof>
Permalink:  ../20010202000841.A1197@frithjof/
Also on:    postgresql.org/message-id/20010202000841.A1197@frithjof

 · 

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: areiner@tph.tuwien.ac.at
  Subject: Re: how to create this trigger?
  In-Reply-To: <20010202000841.A1197@frithjof>
  References: <KJEFJKLOGBDOOKFDDKKLMEMGCCAA.ramiroa@coordinadora.com.co> <20010202000841.A1197@frithjof>

* 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