Function RETURNS SETOF ??? - Mailing list pgsql-general

From Thalis A. Kalfigopoulos
Subject Function RETURNS SETOF ???
Date
Msg-id Pine.LNX.4.21.0106041945040.14315-100000@aluminum.cs.pitt.edu
Whole thread Raw
Responses How to Alter tables with ARRAY? Help PLease  (Igor <dbmanager@osb368.nnov.ru>)
Re: Function RETURNS SETOF ???  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-general
Helloppl,

I have a long query that (summerized) looks something like:

SELECT A.a,B.b
FROM A,B
WHERE A.x=B.x AND (A.y=const1 OR A.y=const2 OR A.y=const3);

where the user provides const1,2,3 at runtime. The problem is in creating a function out of it:
CREATE FUNCTION myfunc(int4,int4,int4) RETURNS <???????> AS 'SELECT A.a,B.b FROM A,B WHERE A.x=B.x AND (A.y= $1 OR A.y=
$2OR A.y= $3)' LANGUAGE 'sql'; 

The question is what do I set as the return value? I'm returning a SETOF something but not something specific to put in
placeof <???????>. I tried 'RETURNS SETOF (int4,int4)' but didn't work. 

One workaround I figured was to create a new view that would give the schema definition I need to reference in my
'RETURNSSETOF' clause. This succeeds in creating the function, but the function doesn't work. I do a select
myfunc(1,2,3)and I get something like: 

 ?column?
-----------
 136361584
 136361584
 136361584
(3 rows)

At first I thought it was oids, but the aren't.
Any ideas what this result is and how I can make this thing work?

thanks in advance,
thalis


pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Re: Updating views
Next
From: Tom Lane
Date:
Subject: Re: Re: Updating views