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
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general