Re: Access NEW and OLD from function called by a rule

Поиск
Список
Период
Сортировка
От Frodo Larik
Тема Re: Access NEW and OLD from function called by a rule
Дата
Msg-id 42FE4831.6040007@elasto.nl
обсуждение исходный текст
Ответ на Re: Access NEW and OLD from function called by a rule  (Frodo Larik <lists@elasto.nl>)
Список pgsql-general
Frodo Larik wrote:

> That means I have to create functions like insert_person(workers) ,
> insert_person(othertable) and function insert_person(anothertable).

I found the solution to this "problem". Create a function with a
Polymorphic Type (notice the anyelement):

CREATE OR REPLACE FUNCTION insert_person(anyelement) RETURNS integer AS $$
   BEGIN
      INSERT INTO persons ( first_name, last_name )
         VALUES ( $1.first_name, $1.last_name );
      RETURN currval('persons_id_seq');
   END
$$ LANGUAGE 'plpgsql';


more infor here:
http://www.postgresql.org/docs/8.0/interactive/extend-type-system.html#EXTEND-TYPES-POLYMORPHIC

sincerely,

Frodo Larik

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

Предыдущее
От: marcelo Cortez
Дата:
Сообщение: Re: query optimization
Следующее
От: CSN
Дата:
Сообщение: Removing tsearch2 from a database