Jeff Ross <jross@xxxxxxxxxx> writes: > On 04/25/10 14:20, Tom Lane wrote: >> Uh, you're using that as the destination for the FOR loop's SELECT. >> What exactly is the purpose of having a second SELECT within the loop? > How else do I get the results I want--name, address, city, state, and so > on through the list out to whatever calls this function? Well, you could do SELECT all-that-stuff INTO some-record-variable FROM ...; RETURN NEXT some-record-variable; which is more or less what the error message is suggesting. Or you could merge the computations you want into the first SELECT (the one in the FOR) and just RETURN NEXT directly from the FOR's loop variable, instead of having two record variables. Or you could eliminate the explicit loop altogether and just RETURN QUERY one-big-query (if you're using a PG version new enough to have RETURN QUERY). regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general