pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan M. Gardner <jgardner@jonathangardner.net>
To: phil@cobol-africa.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Triggers
Date: Fri, 5 Mar 2004 08:32:37 -0800
Message-ID: <200403050832.40529.jgardner@jonathangardner.net> (raw)
In-Reply-To: <NEBBKNKPCLAAGALDLMCBEEOPCHAA.phil@cobol-africa.com>
References: <NEBBKNKPCLAAGALDLMCBEEOPCHAA.phil@cobol-africa.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 26 February 2004 2:18 am, Philip J. Boonzaaier wrote:
> The technical reference gives an example of a trigger on a table -
> employee Just to test this, I have created the following table,
> CREATE TABLE employee
> (name VARCHAR(30),
> age int4,
> state VARCHAR(2),
> manager VARCHAR(3),
> adult VARCHAR(3));
>
> The I created a simple Function, as follows :
>
> CREATE FUNCTION trig_insert_update_check_emp() RETURNS opaque AS '
> BEGIN
> IF new.age > 20 THEN
> new.adult = ''yes'';
> ELSE
> new.adult = ''no'';
> END IF;
> END;
> ' LANGUAGE 'plpgsql';

Couple of comments:
1) Your trigger functions needs to return something. In this case, you 
would "RETURN NEW".
2) I believe trigger functions need to "RETURNS TRIGGER", not "RETURNS 
opaque", but I could be wrong. Give that a try.

Question:
1) What version of PostgreSQL are you running?

- -- 
Jonathan Gardner
jgardner@jonathangardner.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFASKulqp6r/MVGlwwRAgpLAKCycwL/i+/mb6bW1W4QjHKBO9e0xQCgl42q
pmohSw7PZiuIWgOQXxtgvI0=
=4iDJ
-----END PGP SIGNATURE-----



view thread (34+ messages)  latest in thread

Message-ID: <200403050832.40529.jgardner@jonathangardner.net>
Permalink:  ../200403050832.40529.jgardner@jonathangardner.net/
Also on:    postgresql.org/message-id/200403050832.40529.jgardner@jonathangardner.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jgardner@jonathangardner.net, phil@cobol-africa.com
  Subject: Re: Triggers
  In-Reply-To: <200403050832.40529.jgardner@jonathangardner.net>

* 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