pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Howard Williams <howieshouse@home.com>
To: pgsql-general@postgresql.org
Subject: trigger/function question
Date: Sun, 13 May 2001 14:57:38 -0700
Message-ID: <9dn03g$p4u$1@news.tht.net> (raw)

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





view thread (12+ messages)  latest in thread

Message-ID: <9dn03g$p4u$1@news.tht.net>
Permalink:  ../9dn03g$p4u$1@news.tht.net/
Also on:    postgresql.org/message-id/9dn03g$p4u$1@news.tht.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: howieshouse@home.com
  Subject: Re: trigger/function question
  In-Reply-To: <9dn03g$p4u$1@news.tht.net>
  References: <9dn03g$p4u$1@news.tht.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox