I'm having some problems with executing functions that takes and returns postgres refcursor in jooq. I have no idea how to approach with instantiation the ref, which is Result<Record> and how to loop through the records I should get from the function I want to execute.
Let's say I have a following function in postgres (postgres 9.5):
create or replace function foo_cursor(name character varying, ref refcursor)
returns refcursor
as $func$
begin
open ref for
select id, first_name, last_name
from students
where first_name = name;
return ref;
end
$func$
language plpgsql;
And in postgres I'm executing in like that:
begin;
select foo_cursor('Konrad', 'my_cursor');
fetch all in "my_cursor";
commit;
The function has to stay the same - it returns refcursor and takes refcursor.
And I want to execute it in jOOQ:
Routines.fooCursor(configuration, "Konrad", ____);
But I don't know what to put inside the ____, which takes Result<Record>. I tried something like:
Result<Record> records = DSL.using(configuration).newResult();
but it also didn't work.