Re: Bug #440: trigger can not find a function
Stephan Szabo <acroyear_07030@yahoo.com>
From: "Stephan Szabo" <acroyear_07030@yahoo.com>
To: <am@adomos.com>, <pgsql-bugs@postgresql.org>
Date: 2001-09-06T15:48:31Z
Lists: 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