PL/pgSQL Question - Mailing list pgsql-general

From Mitch Vincent
Subject PL/pgSQL Question
Date
Msg-id 004d01c084ce$ed739bc0$0200000a@windows
Whole thread Raw
List pgsql-general
I haven't used PL/pgSQL very much but it looks like a good language in which
to make some simple functions for this application I'm writing..

Is it possible (with PL/pgSQL) to access other records in other tables than
the tuple that pulled the trigger (and called the function)?

Say this (pseudo code):

When a record is added to the invoice_payments table have a trigger fire and
call this function :

total_invoice()

exec_sql -> UPDATE invoices SET total = total + <amount in amount_field in
the tuple> WHERE invoice_id=<value in the invoice ID of this tuple>



That's basically all I'd have to do.. There are a lot of these things that
could be handled by the backend and would make my life much easier..

I looked in the documentation but the examples only talk about rearranging
values within the tuple that fired the trigger which called the function
(wow, a mouth full).

Thanks!

-Mitch



pgsql-general by date:

Previous
From: Alexander Jerusalem
Date:
Subject: Re: [HACKERS] Re: postgres memory management
Next
From: Bruce Momjian
Date:
Subject: Re: OID/XID allocation (was Re: is PG able to handle a >500 GB Database?)