Lists: | pgsql-general |
---|
From: | Joel Palmius <joel(dot)palmius(at)mh(dot)se> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | "Custom" records? |
Date: | 2002-09-19 09:53:25 |
Message-ID: | Pine.LNX.4.44.0209191144210.15296-100000@ligur.student.mh.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Before asking this, I suspect that the answer is no, but I'll ask anyway.
Is there a way to return a completely custom column/row record from a
plpgsql function?
I'd want a function "Descriptives(int)" with results to looking like the
below when SELECT:ed :
measurement | value
------------+------
Mean | 15.8
Median | 16.0
Std.dev | 0.8
Max | 38.0
Min | 0.0
If not possible in plpgsql, is there a workaround while still not having
an external program fetching a lot of data from the DB to do the
calculation?
// Joel
From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | Joel Palmius <joel(dot)palmius(at)mh(dot)se> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: "Custom" records? |
Date: | 2002-09-20 05:01:35 |
Message-ID: | 87ptv96yq8.fsf@mailbox.samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Joel Palmius <joel(dot)palmius(at)mh(dot)se> writes:
> Is there a way to return a completely custom column/row record from a
> plpgsql function?
If I understand you correctly, you should be able to do this in 7.3.
http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html
(see RETURN NEXT)
Set-returning functions can also be defined using C or SQL.
Cheers,
Neil
--
Neil Conway <neilc(at)samurai(dot)com> || PGP Key ID: DB3C29FC
From: | "Peter Darley" <pdarley(at)kinesis-cem(dot)com> |
---|---|
To: | "Joel Palmius" <joel(dot)palmius(at)mh(dot)se>, "pgsql-general" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: "Custom" records? |
Date: | 2002-09-24 16:50:36 |
Message-ID: | NNEAICKPNOGDBHNCEDCPKEJJCOAA.pdarley@kinesis-cem.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Joel,
I don't have an answer for this, but I do have a question.
I couldn't find any way to get a median native in PostgreSQL, did you write
a median function or some such? If so, would you be willing to share it?
Thanks,
Peter Darley
-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Joel Palmius
Sent: Thursday, September 19, 2002 2:53 AM
To: pgsql-general
Subject: [GENERAL] "Custom" records?
Before asking this, I suspect that the answer is no, but I'll ask anyway.
Is there a way to return a completely custom column/row record from a
plpgsql function?
I'd want a function "Descriptives(int)" with results to looking like the
below when SELECT:ed :
measurement | value
------------+------
Mean | 15.8
Median | 16.0
Std.dev | 0.8
Max | 38.0
Min | 0.0
If not possible in plpgsql, is there a workaround while still not having
an external program fetching a lot of data from the DB to do the
calculation?
// Joel
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
From: | Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp> |
---|---|
To: | "Peter Darley" <pdarley(at)kinesis-cem(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: "Custom" records? |
Date: | 2002-09-29 16:46:50 |
Message-ID: | 20020930014057.8F01.RK73@sea.plala.or.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Tue, 24 Sep 2002 09:50:36 -0700
"Peter Darley" <pdarley(at)kinesis-cem(dot)com> wrote:
> Joel,
> I don't have an answer for this, but I do have a question.
> I couldn't find any way to get a median native in PostgreSQL, did you write
> a median function or some such? If so, would you be willing to share it?
> Thanks,
> Peter Darley
Here is one of ways to get median values.
http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=5486
Regards,
Masaru Sugawara