function/trigger questions

From: Richard Welty <rwelty(at)averillpark(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: function/trigger questions
Date: 2001-10-03 22:01:43
Message-ID: E15ouAD-0005IP-00@krusty-motorsports.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

i'm new to this list, and fairly new (3-4 weeks) to postgresql
(additionally, my knowledge of relational databases is largely theoretical,
or at least, was such when i started this project.)

anyway, i have a couple of things i'm trying to resolve with stored
procedures and triggers, and seem to have pushed to the boundaries of the
documentation. what follows is a rough outline of the problem, with some
questions about the best way to crack it:

i have a table where, whenever rows are inserted, i need to perform a
number of steps for each row. i need to insert rows into two other
tables (this is easy using pl/pgsql, which i'm already successfully doing
for another similar situation.) the tougher part is that for each row, i
need to send an email to a contact address.

my current proposed approach is to write most of this in pl/pgsql, and have
the pl/pgsql call a c function whose purpose is to compose and send an
email from its arguments (to, subject, various message bits and pieces) and
send it. the documentation is seemingly thin on such topics (the Momjian
book presents a trivial example at the beginning of chapter 19, and then
says to go look at pgsql/src/backend/utils/adt for examples to copy.)

if i can get the argument passing (of character strings) from pl/pgsql to c
right then the rest should be easy; is there any documentation or examples
available of passing a bunch of strings from pl/pgsql to c (from the looks
of it, if a c function is callable from sql it is callable from pl/pgsql,
but i'm making an assumption there.)

thanks for any help or insights,
richard

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-10-03 22:21:12 Re: function/trigger questions
Previous Message Mihai Gheorghiu 2001-10-03 21:14:08 Rules and triggers