Search for sample pg stored procedure

Поиск
Список
Период
Сортировка
От Dwayne Miller
Тема Search for sample pg stored procedure
Дата
Msg-id 3E553A4A.3030808@espgroup.net
обсуждение исходный текст
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Table Partitioning in Postgres:
Следующее
От: P G
Дата:
Сообщение: Re: What is the quickest query in the database?