Function RETURNS SETOF ???

From: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Function RETURNS SETOF ???
Date: 2001-06-05 00:24:48
Message-ID: Pine.LNX.4.21.0106041945040.14315-100000@aluminum.cs.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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= $2 OR 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 place of <???????>. 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 'RETURNS SETOF' 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-06-05 01:42:57 Re: Re: Updating views
Previous Message Stephan Szabo 2001-06-05 00:13:39 Re: Re: Updating views