Search Postgresql Archives

Re: Record with a field consisting of table rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15 Jan 2011, at 21:57, Jon Smark wrote:

>> No, of course not. A function cannot return different
>> amounts of different return-values in any language I know
>> of.
> 
> Come on, you make it sound like it's something inconceivable or exotic,
> even though pretty much any strongly-typed language with a post-1970s
> type-system will allow a function to return tuples of arbitrary values.
> Have you never come across Ocaml, Haskell, Scala, and so forth?


A tuple wouldn't be unusual, but you're not asking for a simple tuple here. What you're asking for is a value and a set of tuples. That would sort of look like this:

total | users
---------------------------------------------------------
 3    | foo
      | bar
      | baz

And what's worse, after the first returned tuple you only seem to want the users value, without the total value. I don't know of any language that can do that and I'm pretty sure the languages you mentioned can't do that either. It makes parsing the return values unnecessary difficult, I bet that's a compelling enough reason that nobody seems to have implemented it.


What most languages, including pgsql, _can_ do is this:

total | users
---------------------------------------------------------
 3    | foo
 3    | bar
 3    | baz


Or this:

total | users
---------------------------------------------------------
 3    | [foo, bar, baz]


Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


!DSPAM:737,4d32398a11872893390349!



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux