Re: Record with a field consisting of table rows

From: Jon Smark <jon(dot)smark(at)yahoo(dot)com>
To: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Record with a field consisting of table rows
Date: 2011-01-16 16:40:45
Message-ID: 824154.39839.qm@web112807.mail.gq1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

> 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.

Which is in itself a tuple! This discussion is again veering slightly
off-topic, but note that tuples as mathematical objects do not have such
arbitrary limitations.

> 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.

Again, you're making it sound like I'm requesting something exotic,
while any language with a modern type system allows this and much
more without blinking. In Ocaml, for example, the return type 'page_t'
of my function could be defined as follows:

type user_t = { uid: int; name: string; age: int; }
type page_t = int * user_t list

('user_'t is declared as a record with fields 'uid', 'name', and 'age';
'page_t' is defined as a tuple consisting of an integer and a list of
'user_t').

Moreover, we've already established that PL/pgSQL also allows the return
of a tuple consisting of an integer and an array of tuples. All I wanted
was to change the latter portion into SETOF tuples...

Best regards,
Jon

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mag Gam 2011-01-16 16:44:48 database slowdown
Previous Message Andy Colson 2011-01-16 16:08:57 Re: How to generate unique invoice numbers for each day