From: | Mike Christensen <imaudi(at)comcast(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Question about functions that return a set of records |
Date: | 2009-02-20 06:50:52 |
Message-ID: | 499E52CC.1060006@comcast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have the following function:
CREATE FUNCTION foo(_userid uuid)
RETURNS SETOF record AS
$BODY$
BEGIN
RETURN QUERY
select n.UserId, u.Alias, n.Date, n.Data
--Bunch of joins, etc
If I understand correctly, I have to return "SETOF record" since my
result set doesn't match a table and isn't a single value. However,
this means when I want to call it I have to provide a column definition
list, such as:
select * from foo as (...);
Is there any way to specify this column list within the function
itself? The problem I'm running into is I want to call this function
using Npgsql which doesn't appear to support passing in a column
definition list.
One idea is to use a view and then have the function select * from the
view and apply the where clause. However, I'm not sure if this would be
as performant since views may not be indexed (dunno if this is true or
not)..
Any other ideas would be appreciated.. Thanks!
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Asko Oja | 2009-02-20 07:00:09 | Re: Question about functions that return a set of records |
Previous Message | Scott Marlowe | 2009-02-20 05:31:26 | Re: Query with date where clause is very slow |