Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux