Re: Passing row set into PL/pgSQL function.

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Passing row set into PL/pgSQL function.
Дата
Msg-id 505B0FC2.8080302@ringerc.id.au
обсуждение исходный текст
Ответ на Passing row set into PL/pgSQL function.  (Lucas Clemente Vella <lvella@gmail.com>)
Список pgsql-general
On 09/20/2012 01:47 PM, Lucas Clemente Vella wrote:
>> http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/
>
> I have already seen this page, I am OK in running SERIALIZABLE
> transactions, and have no problem in replaying failed transactions due
> to race condition. Anyway, that is completely off my issue: I need
> upsert and I am prepared to deal with it. I just want to save typing
> by creating a reusable function.

In that case, maybe you could have your function accept a `refcursor`?

DECLARE some_curs CURSOR FOR VALUES ('a',1), ('b',2), ('c',3);
SELECT funky_upsert('table', ARRAY['col1','col2'], 'some_curs');
CLOSE some_curs;

Internally it could fetch rows from the refcursor into record fields and
do what it needed.

Personally I'd just do the work app-side.

--
Craig Ringer



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

Предыдущее
От: Martin French
Дата:
Сообщение: Re: Need psql send email
Следующее
От: "David Johnston"
Дата:
Сообщение: Re: RFE: Column aliases in WHERE clauses