Re: triggers problems whit function - Mailing list pgsql-general

From Fernando Moreno
Subject Re: triggers problems whit function
Date
Msg-id b1c45530810221359x2ef7887do6dd12b3719f0acb3@mail.gmail.com
Whole thread Raw
In response to triggers problems whit function  (Ma. Cristina Peña C. <mpena@sensacd.com.mx>)
Responses Re: triggers problems whit function  (Guillaume Lelarge <guillaume@lelarge.info>)
List pgsql-general
2008/10/22 Ma. Cristina Peña C. <mpena@sensacd.com.mx>

I want to use a function in to a trigger

 

This is my

CREATE FUNCTION "subradio"(integer) RETURNS integer AS 'select cast(count (claveubica) as integer ) from asradios where ubicacion =0;' LANGUAGE 'sql';

 

And my ttrigger is

CREATE TRIGGER validaradios AFTER DELETE ON subestacion FOR EACH ROW EXECUTE PROCEDURE subradio(0);

 

But I got an error

ERROR:  CreateTrigger: function subradio() does not exist

 

What can I do??

A trigger function must have a specific structure, it takes no arguments and returns "trigger". Besides, trigger functions are supposed to do some processing before or after insert, update or delete operations, so there's no sense in returning a row count.

Take a look at the docs, specially chapter 35 and 38.9.

Cheers.

pgsql-general by date:

Previous
From: Ma. Cristina Peña C.
Date:
Subject: triggers problems whit function
Next
From: Alexander Kuprijanov
Date:
Subject: how to split coordinates from point