0

IN my postgresql 13.2 version database, the "refcursor" is not working. when am i storing the select query output to refcursor variable, it is throwing below error.

create function testing(val character varying)
return t_cur
language plpgsql
as $function$
declare
v_return t_cur;
begin
open v_return.v_output for select * from tbl_master where id = val;
return v_return;
end;
$function$

In this stored procedure "t_cur" is user defined type. and v_output is refcursor variable.

Error:

Error: cursor variable must be a simple variable
LINE 67: open V_RETURN.V_OUTPUT for select * from...

This same stored procedure is working properly in postgresql version 9.6

So please explain what is replacement of refcursor in postgresql 13.2 verson. or what is the solution for this?

  • Why use a refcursor at all? You can define the function as `returns table (...)` or even `returns setof tbl_master` and return the result directly. –  Mar 07 '23 at 13:58
  • i am executing this sp through PHP program. and getting the tbl_master table output through that cursor veriable. – Kannadasan bksys Mar 07 '23 at 14:29

0 Answers0