I have a simple PostgreSQL function..something like below
CREATE FUNCTION reffunc(refcursor) RETURNS refcursor AS '
BEGIN
OPEN $1 FOR
SELECT col
FROM test
WHERE cola = 1;
RETURN $1;
END;
' LANGUAGE plpgsql;
the thing is when I run the following sql, say I get 10 rows
SELECT col
FROM test
WHERE cola = 1;
but when i call the function i get 0 rows back, later after varying the script i found that the following works
CREATE FUNCTION reffunc(refcursor) RETURNS refcursor AS '
BEGIN
OPEN $1 FOR
SELECT col
FROM test t
WHERE t.cola = 1;
RETURN $1;
END;
' LANGUAGE plpgsql;
and returns the necessary rows.
I know this is not strictly a SQL issue, but is this a well known PostgreSQL issue or possibly a bug?
A point of note here is that I have a number of tables with columns named 'cola', is that the reason or is there a PostgreSQL config issue?
32bit Windows version of PostgreSQL v8.3