Re: How to return a resultset/table from a sql function?

From: "Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)nl>
To: "Pgsql-General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to return a resultset/table from a sql function?
Date: 2005-01-12 23:06:58
Message-ID: A3D1526C98B7C1409A687E0943EAC41001EB30@obelix.askesis.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

OK, to answer my own question (typo's possible, works here ;-)):

CREATE TYPE abonnementartikelheader AS (col1 int4, col2 int4);

CREATE OR REPLACE FUNCTION getabonnementartikelheader(int4)
RETURNS SETOF abonnementartikelheader AS
'
select
(SELECT COUNT(klantnummer)::int4 FROM abo_klt WHERE abonnement = $1),
(SELECT SUM(aantal_abonnementen)::int4 FROM abo_klt WHERE abonnement = $1);
'
LANGUAGE 'sql' VOLATILE;

Groeten,

Joost

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-12 23:12:37 Re: index on user defined type
Previous Message Stephan Szabo 2005-01-12 22:56:59 Re: index on user defined type