Re: writing functions with return type record

From: Justin Clift <justin(at)postgresql(dot)org>
To: Roberto Bellandi <roberto(at)b2tel(dot)it>
Cc: pgsql-www(at)postgresql(dot)org
Subject: Re: writing functions with return type record
Date: 2017-02-14 15:53:57
Message-ID: FC5E72EA-F0A4-41DF-9F9B-470F47255FEF@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-www

Hi Roberto,

This is probably not the mailing list you're after. This one is for
people doing stuff with the PostgreSQL website infrastructure.

At a guess, you're probably after the "pgsql-general" mailing list
instead. Sorry for having to bounce you around. ;)

https://www.postgresql.org/list/pgsql-general/

Subscribe here:

https://www.postgresql.org/community/lists/subscribe/

Regards and best wishes,

Justin Clift

> On 14 Feb 2017, at 15:24, Roberto Bellandi <roberto(at)b2tel(dot)it> wrote:
>
> Hi, i'am try to encapsulate some logic into funtions to clear design,
>
> my question is:
>
> CREATE OR REPLACE FUNCTION get_something(various param)
> RETURNS SETOF mydummytable AS
> $BODY$
> DECLARE
> v_rec mydummytable%rowtype;
> BEGIN
> FOR v_rec IN (select field1, field2 blabla)
> LOOP
> RETURN NEXT v_rec;
> END LOOP;
> RETURN;
> END;
> $BODY$
> LANGUAGE plpgsql VOLATILE
> COST 100
> ROWS 1000;
>
> with mydummytable a real empty table
> i can use function in query like this
>
> select field1 from get_something(...)
>
> without creation of table mydummytable and use in function type RECORD
>
> i can use
> select field1 from get_something(...)a (field1 type, field2 type,...)
>
> is possible and if yes how to write function return rowset or where store mydummytable structure without create table mydummytable
> and use function in query like this select field1 from get_something(...) without a (field1 type, field2 type,...) definition
>
> PS i read about resultset fully retrieve , my query in function at maximum return one or two row
>
>
>
>
> --
> Sent via pgsql-www mailing list (pgsql-www(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-www

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi

In response to

Browse pgsql-www by date

  From Date Subject
Next Message Daniel Gustafsson 2017-02-14 22:18:58 Fix div in paragraph on redhat download
Previous Message Roberto Bellandi 2017-02-14 15:24:06 writing functions with return type record