From: | "john huttley" <john(at)mwk(dot)co(dot)nz> |
---|---|
To: | "PostgreSQL-general" <pgsql-general(at)postgreSQL(dot)org>, <wieck(at)debis(dot)com> |
Subject: | Create Triggers Documentation Error |
Date: | 2000-04-30 04:37:43 |
Message-ID: | 000901bfb25d$d36b7200$ca5fa8c0@hisdad.org.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Quite a few people (including me) have had problems with creating triggers.
Last week Jan gave us the definative answer.
No,
trigger procedures in Postgres are allways defined to take no
arguments and have a return type "opaque".
The main error above is, that the "sql" language cannot be
used to define a trigger!
Use the PL/pgSQL or PL/Tcl languages instead. They're
documented in the programmers manual. Version 7.0 will have
PL/Perl too, but I don't know if that one can be used for
trigger procs yet.
Jan
But look at this snippet from the Docs on 'Create Trigger'
It is definately passing parameters to the trigger procedure.
Something needs to be fixed up here. Preferably in a way that lets us
pass parameters to trigger procedures!!
Usage
Check if the specified distributor code exists in the distributors table
before appending or updating a row in the table films:
CREATE TRIGGER if_dist_exists
BEFORE INSERT OR UPDATE ON films FOR EACH ROW
EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
Before cancelling a distributor or updating its code, remove every reference
to the table films:
CREATE TRIGGER if_film_exists
BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films',
'did');
Regards
john
From | Date | Subject | |
---|---|---|---|
Next Message | nathan | 2000-04-30 09:32:00 | textsubstr() ...? for postgres 7 beta5 |
Previous Message | Tom Lane | 2000-04-30 04:04:07 | Re: 7.0RC1: possible query and backend problem |