| From: | Frodo Larik <lists(at)elasto(dot)nl> |
|---|---|
| To: | Frodo Larik <lists(at)elasto(dot)nl> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Access NEW and OLD from function called by a rule |
| Date: | 2005-08-13 19:21:21 |
| Message-ID: | 42FE4831.6040007@elasto.nl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | CSN | 2005-08-13 22:10:17 | Removing tsearch2 from a database |
| Previous Message | marcelo Cortez | 2005-08-13 18:28:01 | Re: query optimization |