Обсуждение: Returning just one resultset from function call with refcursor return
Returning just one resultset from function call with refcursor return
От
"Francisco Figueiredo Jr."
Дата:
Hi guys, I'd like to know how you are doing to return a cursor resultset from function call. I know, from documentation, that I can do the following: CREATE TABLE test (col text); INSERT INTO test VALUES ('123'); CREATE FUNCTION reffunc(refcursor) RETURNS refcursor AS ' BEGIN OPEN $1 FOR SELECT col FROM test; RETURN $1; END; ' LANGUAGE plpgsql; BEGIN; SELECT reffunc('funccursor'); FETCH ALL IN funccursor; COMMIT; The problem is that when I execute the lines above I get: reffunc ------------ funccursor (1 row) col ----- 123 (1 row) I'd like to omit the reffunc resultset return and get directly the col resultset. Is this possible? Thanks in advance. Please, let me know if this is not the appropriated place to do such questions. Regards, Francisco Figueiredo Jr.
Francisco Figueiredo Jr. wrote: > I'd like to omit the reffunc resultset return and get directly the col > resultset. Is this possible? See http://www.postgresql.org/docs/7.4/static/jdbc-callproc.html. -O
Re: Returning just one resultset from function call with refcursor
От
"Francisco Figueiredo Jr."
Дата:
Oliver Jowett wrote: > Francisco Figueiredo Jr. wrote: > >> I'd like to omit the reffunc resultset return and get directly the col >> resultset. Is this possible? > > > See http://www.postgresql.org/docs/7.4/static/jdbc-callproc.html. > > -O > Hi Oliver, thanks for the tip. But I'd like to know how internally you handle the two resultsets return and returns only one to user. Do you make special handling of the return type of the function? I mean, if you check that the function returns a refcursor, you eat the first resultset and shows to user just the second? If so, could you point me where I could find the metadata about the function return type? Thanks in advance. Regards, Francisco Figueiredo Jr.