trigger/function question

From: "Howard Williams" <howieshouse(at)home(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: trigger/function question
Date: 2001-05-13 21:57:38
Message-ID: 9dn03g$p4u$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello there!

I need to perform a one-to-many insert based on the insert or update on a
table.

I'm not sure if it's possible without a loadable c module. I'm hoping it
is. Can't find a built-in looping mechanism.

I have tables A, B, and C. On every update or insert on A, I need to insert
a row in B for every row in C.

Here's a skeleton of my plan:

CREATE FUNCTION line_items_trig_func ( character varying(20), character
varying(20), character varying(50),
character varying(500), character varying(40), int2, int4, int4,
int4, character varying(20),
int2, timestamp, bool, character varying(20) ) returns boolean
as '' (some kind of for each in (select * from C) (insert intoB))"
LANGUAGE 'sql';
CREATE TRIGGER line_items_trigger AFTER INSERT or UPDATE on line_items
FOR EACH STATEMENT EXECUTE PROCEDURE ('col1', 'col2', ...);

Thanks,

howie

Browse pgsql-general by date

  From Date Subject
Next Message Per-Olof Pettersson 2001-05-13 23:20:14 DISTINCT ON () with UNION
Previous Message Louis-David Mitterrand 2001-05-13 20:36:23 Re: Invoices