Re: Passing row set into PL/pgSQL function. - Mailing list pgsql-general

From Craig Ringer
Subject Re: Passing row set into PL/pgSQL function.
Date
Msg-id 505B0FC2.8080302@ringerc.id.au
Whole thread Raw
In response to Passing row set into PL/pgSQL function.  (Lucas Clemente Vella <lvella@gmail.com>)
List 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 by date:

Previous
From: Martin French
Date:
Subject: Re: Need psql send email
Next
From: "David Johnston"
Date:
Subject: Re: RFE: Column aliases in WHERE clauses