Skip site navigation (1) Skip section navigation (2)

Problem creating trigger

From: Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)net>
To: pgsql-novice novice <pgsql-novice(at)postgresql(dot)org>
Subject: Problem creating trigger
Date: 2012-06-17 00:51:57
Message-ID: 4996D5AE-B6B7-458B-980B-1645AEC4C591@internode.on.net (view raw or flat)
Thread:
Lists: pgsql-novice
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
' UPDATE company SET co_has_branch_sa=CASE WHEN (SELECT sum(br_ca_rate_sa) FROM branch WHERE br_co_id=$1)>0 THEN TRUE ELSE FALSE END
 WHERE co_id=$1 RETURNING 1; '
 LANGUAGE sql VOLATILE
 COST 100;
ALTER FUNCTION detect_branch(integer)
OWNER TO postgres;

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".

Can some kind soul tell me why?

Michael Rowan
mike(dot)rowan(at)internode(dot)on(dot)net

11 Kingscote Street
ALBERTON
South Australia 5014

tel 618 8240 3993
mob 0417 812 509




Responses

pgsql-novice by date

Next:From: Jeff DavisDate: 2012-06-17 01:40:55
Subject: Re: Planning a Large RDBMS
Previous:From: e-letterDate: 2012-06-16 06:53:01
Subject: Re: create table from regular expressions applied to rows of multiple tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group