| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| To: | Harpreet Dhaliwal <harpreet(dot)dhaliwal01(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Trigger (Calling a Procedure) |
| Date: | 2006-08-16 05:50:55 |
| Message-ID: | 20060816055055.GA50975@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, Aug 16, 2006 at 01:35:47AM -0400, Harpreet Dhaliwal wrote:
> I'm trying to create a trigger with the following definition:
>
> CREATE TRIGGER insert_price_change AFTER INSERT OR DELETE OR UPDATE ON
> raw_email
> FOR EACH ROW EXECUTE PROCEDURE add_one(1);
>
> Procedure / Function add_one has the following definition
>
> CREATE FUNCTION add_one(integer) RETURNS integer
> AS '/usr/local/pgsql/jsb/add_one', 'add_one'
> LANGUAGE C STRICT;
>
> function add_one is running fine.
>
> When I try to create the trigger insert_price_change, it throws me the
> follwoing error:
>
> ERROR: function add_one() does not exist
Trigger functions must return type "trigger" and they must be
declared with no arguments. You can pass an argument as in your
CREATE TRIGGER statement but a trigger function receives its arguments
differently than an ordinary function. See the Triggers chapter
in the documentation, especially "Writing Trigger Functions in C":
http://www.postgresql.org/docs/8.1/interactive/triggers.html
Unless you need to use C I'd suggest using PL/pgSQL. Even if you
do need to use C I'd recommend practicing with PL/pgSQL to learn
the basics with a simpler language.
http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html
--
Michael Fuhr
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Fuhr | 2006-08-16 05:54:19 | Re: [NOVICE] DB insert Error |
| Previous Message | Jasbinder Bali | 2006-08-16 05:49:25 | Re: DB insert Error |