how to create this trigger?

Поиск
Список
Период
Сортировка
От Ramiro Arenas Ramírez
Тема how to create this trigger?
Дата
Msg-id KJEFJKLOGBDOOKFDDKKLMEMGCCAA.ramiroa@coordinadora.com.co
обсуждение исходный текст
Ответы Re: how to create this trigger?  ("Albert REINER" <areiner@tph.tuwien.ac.at>)
Список pgsql-sql
I need to create a trigger that increment a value in a column 
of table1 where a row is inserted in table 2

I have tried whit this but it just does nothing.

CREATE FUNCTION increment_value () RETURNS opaque AS 
'DECLARE  code int4;  BEGIN  code := new.code;  UPDATE table1   SET value = value + 1  WHERE id = code;
RETURN NEW;
END;'  LANGUAGE 'plpgsql';

CREATE TRIGGER insert_on_table2 BEFORE INSERT ON table2 FOR EACH ROW EXECUTE PROCEDURE increment_value();


Can you help me? 





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

Предыдущее
От: "Albert REINER"
Дата:
Сообщение: PL/pgSQL: possible parsing or documentation bug?
Следующее
От: Michael Davis
Дата:
Сообщение: RE: how to create this trigger?