Re: function to return query result - Mailing list pgsql-general

From Ashley Clark
Subject Re: function to return query result
Date
Msg-id 20001129084334.A22781@ghoti.org
Whole thread Raw
In response to function to return query result  (Peter Maas <pm@mrinfo.de>)
List pgsql-general
* Peter Maas in "[GENERAL] function to return query result" dated
* 2000/11/29 12:34 wrote:

> Hi,

Hi,

> I tried to write a PL/PGSQL function that returns a query result:

I don't think you can do that yet, but let's look at what you've got.

> CREATE FUNCTION pms() RETURNS pmsummen AS '
> declare
>     result pmsummen;
> BEGIN
>     select into result * from pmsummen;
>     return result;
> END;
> ' LANGUAGE 'plpgsql';

Yeah, the return value of a function can't be a recordset.

> I tried lots of variations of this function (employing PERFORM,
> replacing pmsummen by record, ...) but everything failed. My first
> intention was to write a parameterized view but this doesn't seem to
> exist in PostgresQL so I tried to write a function returning a query
> result. Thanks for your help.

Why don't you use a view? Something like:

create view test as select a.a, a.b, a.c, b.a, b.b
from a, b
where a.id=b.id;

Then you can do selects on the view using a where clause:

select *
from test
where a.a='somevalue';

--
ashley clark

Attachment

pgsql-general by date:

Previous
From: "Gordan Bobic"
Date:
Subject: Re: insertion times ..
Next
From: "Bryan White"
Date:
Subject: Re: insertion times ..