From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Philipp Kraus <philipp.kraus@tu-clausthal.de>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: sql function with empty row
Date: Wed, 16 May 2018 12:59:11 -0700
Message-ID: <6dc24153-7c52-4bcd-1b2b-5ff31a1f3fec@aklaver.com> (raw)
In-Reply-To: <72B01876-DA02-4306-9994-F7F1F12A7C29@tu-clausthal.de>
References: <A5624A8E-1E70-49BC-9CBB-798AE6F8276F@tu-clausthal.de>
<fb79c263-b978-53eb-2a3d-c593e80980e0@aklaver.com>
<72B01876-DA02-4306-9994-F7F1F12A7C29@tu-clausthal.de>
On 05/16/2018 11:49 AM, Philipp Kraus wrote:
>
>> Am 16.05.2018 um 20:40 schrieb Adrian Klaver <adrian.klaver@aklaver.com>:
>>
>
> I have tested it on my data and it works also, but that is a little bit confusing, because imho setof is >= 0 rows and
> without setof it is [0,1]. On this I know there exist only one or no record, so I choose the solution without setof
I gotta believe the difference is:
RETURNS substance
https://www.postgresql.org/docs/10/static/xfunc-sql.html#XFUNC-SQL-TABLE-FUNCTIONS
"
If the function is defined to return a composite type, the table
function produces a column for each attribute of the composite type."
RETURNS SETOF substance
https://www.postgresql.org/docs/10/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET
"When an SQL function is declared as returning SETOF sometype, the
function's final query is executed to completion, and each row it
outputs is returned as an element of the result set."
>
> Thanks for help
>
> Phil
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, philipp.kraus@tu-clausthal.de
Subject: Re: sql function with empty row
In-Reply-To: <6dc24153-7c52-4bcd-1b2b-5ff31a1f3fec@aklaver.com>
References: <A5624A8E-1E70-49BC-9CBB-798AE6F8276F@tu-clausthal.de> <fb79c263-b978-53eb-2a3d-c593e80980e0@aklaver.com> <72B01876-DA02-4306-9994-F7F1F12A7C29@tu-clausthal.de> <6dc24153-7c52-4bcd-1b2b-5ff31a1f3fec@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox