Re: Problem creating trigger
От | Jeff Davis |
---|---|
Тема | Re: Problem creating trigger |
Дата | |
Msg-id | 1339897956.14729.8.camel@jdavis обсуждение исходный текст |
Ответ на | Problem creating trigger (Michael Rowan <mike.rowan@internode.on.net>) |
Список | pgsql-novice |
On Sun, 2012-06-17 at 10:21 +0930, Michael Rowan wrote: > Using PostgreSQL 9.1 I have created my first function. Heres the create statement reported by pgAdminIII: > > CREATE OR REPLACE FUNCTION detect_branch(integer) > RETURNS integer AS ... > Works well. > > However, if I try to create a trigger: > CREATE TRIGGER run_detect_branch > AFTER UPDATE OR INSERT ON branch > FOR EACH ROW > EXECUTE PROCEDURE detect_branch() > > I get an error "function detect_branch() does not exist". 1. You need to write your function in a different language. sql is meant for very simple functions. Try plpgsql: http://www.postgresql.org/docs/9.2/static/plpgsql.html 2. The function should have return type TRIGGER and must be declared to take no arguments: http://www.postgresql.org/docs/9.2/static/sql-createtrigger.html Also, see: http://www.postgresql.org/docs/9.2/static/plpgsql-trigger.html for some examples. Regards, Jeff Davis
В списке pgsql-novice по дате отправления: