Search for sample pg stored procedure

From: "Dwayne Miller" <dmiller(at)espgroup(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Search for sample pg stored procedure
Date: 2003-02-20 20:27:54
Message-ID: 3E553A4A.3030808@espgroup.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm looking for a stored procedure example to do the following:

Given a table something like

create table audit (
aid serial,
amount float,
balance float,
parent aid int)

the sp would be used to find the last entry in the table, take the
balance from that entry and add it to the current amount and do an
insert back into the same table. This would of course grab a lock on the
table so that two pending inserts would occur sequentially. The order
in that case would not be significant as long as the second insert used
the results of the first insert.

I'm really not sure how to do the locking in such an example.

Thanks in advance for any help,
Dwayne

Browse pgsql-general by date

  From Date Subject
Next Message P G 2003-02-20 20:32:27 Re: What is the quickest query in the database?
Previous Message Darren Ferguson 2003-02-20 20:22:44 Re: Postgres Error