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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/users-lounge/docs/faq.html