Re: Access NEW and OLD from function called by a rule - Mailing list pgsql-general

From Frodo Larik
Subject Re: Access NEW and OLD from function called by a rule
Date
Msg-id 42FE4831.6040007@elasto.nl
Whole thread Raw
In response to Re: Access NEW and OLD from function called by a rule  (Frodo Larik <lists@elasto.nl>)
List 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 by date:

Previous
From: marcelo Cortez
Date:
Subject: Re: query optimization
Next
From: CSN
Date:
Subject: Removing tsearch2 from a database