Re: PL/pgSQL: How to return two columns and multiple rows

From: Sven Geggus <lists(at)fuchsschwanzdomain(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/pgSQL: How to return two columns and multiple rows
Date: 2015-06-18 13:47:31
Message-ID: mlui5j$vns$2@solar.geggus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

> CREATE OR REPLACE FUNCTION public.fx(i integer, OUT a text, OUT b text)
> RETURNS SETOF record
> LANGUAGE plpgsql
> AS $function$
> BEGIN
> RETURN QUERY SELECT 'foo'||id, 'bar'||id FROM generate_series(1,i) g(id);
> RETURN;
> END;
> $function$

I'm afraid I will almost certainly be unable to use RETURN QUERY. I have
just broken this down to the posted code to make it easier to understand.

In my real world code a loop will need to iterate over features of a postgis
geometry returning a couple of rows containing a string and a calculated
geometry as a result.

Regards

Sven

--
"Thinking of using NT for your critical apps?
Isn't there enough suffering in the world?"
(Advertisement of Sun Microsystems in Wall Street Journal)
/me is giggls(at)ircnet, http://sven.gegg.us/ on the Web

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sven Geggus 2015-06-18 13:52:02 Re: PL/pgSQL: How to return two columns and multiple rows
Previous Message David G. Johnston 2015-06-18 13:43:51 Re: PL/pgSQL: How to return two columns and multiple rows