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

Reply via email to