create function for trigger question

Поиск
Список
Период
Сортировка
От Barbara Lindsey
Тема create function for trigger question
Дата
Msg-id 1882.216.78.162.114.1068156356.squirrel@webmail.cog.ufl.edu
обсуждение исходный текст
Ответы Re: create function for trigger question  (Darren Ferguson <darren@crystalballinc.com>)
Список pgsql-general

I am a postgres newbie.

I am trying to create a trigger that will put a copy of a record into a
backup table before update or delete. As I understand it, in order to do
this I must have a function created to do this task.
The function I am trying to create is as follows:

CREATE FUNCTION customer_bak_proc(integer)  RETURNS boolean as
'INSERT INTO customer_bak  (SELECT * from customer where id = $1 )'
LANGUAGE 'SQL';

Whenever I try to create this function, I get an error on the return type,
as follows:
ERROR:  function declared to return boolean, but final statement is not a
SELECT

I have tried using text, integer, opaque, NULL, 0, 1.
And I have tried omitting the "RETURNS" clause altogether, but none of
these works.

What is the return data type of an SQL INSERT statement? I think that
would work (?), but I have not been able to find this in any of the
documentation.

Has anyone else successfully written a function to do an insert?
Has anyone else written a trigger to accomplish this kind of task?
Perhaps I am taking the wrong approach...
Thank you for any help.
Barb Lindsey






В списке pgsql-general по дате отправления:

Предыдущее
От: Boris Popov
Дата:
Сообщение: Re: pid of current session?
Следующее
От: Craig O'Shannessy
Дата:
Сообщение: Optimiser desicion bringing system to its knees?