function/trigger questions - Mailing list pgsql-general

From Richard Welty
Subject function/trigger questions
Date
Msg-id E15ouAD-0005IP-00@krusty-motorsports.com
Whole thread Raw
Responses Re: function/trigger questions  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-general by date:

Previous
From: "Seung-won Hwang"
Date:
Subject: Flushing cache?
Next
From: Tom Lane
Date:
Subject: Re: function/trigger questions