Re: Bug #440: trigger can not find a function - Mailing list pgsql-bugs

From Stephan Szabo
Subject Re: Bug #440: trigger can not find a function
Date
Msg-id 009a01c136eb$635f50d0$014ba8c0@myst.com
Whole thread Raw
In response to Bug #440: trigger can not find a function  (pgsql-bugs@postgresql.org)
List pgsql-bugs
> Sample Code
> CREATE FUNCTION check_key(varchar,varchar) RETURNS OPAQUE AS '
> BEGIN
>     IF COUNT(*) FROM $2 WHERE $2.$1=NEW.$1 THEN
>            RAISE EXCEPTION ''integrity violation : duplicated key'';
>     END IF;
>     RETURN NEW;
> END;
> ' LANGUAGE 'plpgsql';
>
> CREATE TRIGGER trigger_check_key BEFORE INSERT OR UPDATE
> ON bar
> FOR EACH ROW EXECUTE PROCEDURE check_key('id','foo');

Trigger functions take no arguments and return opaque.  The arguments given
on the create trigger statement are passed in a special fashion (for plpgsql
look at TG_NARGS and TG_ARGV array).



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #440: trigger can not find a function
Next
From: Peter Eisentraut
Date:
Subject: Re: Build problem with CVS version