【发布时间】:2018-06-06 20:02:41
【问题描述】:
我在执行在 jooq 中接受并返回 postgres refcursor 的函数时遇到了一些问题。我不知道如何实例化ref,即Result<Record>,以及如何遍历我应该从我想要执行的函数中获得的记录。
假设我在 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;
在 postgres 中我是这样执行的:
begin;
select foo_cursor('Konrad', 'my_cursor');
fetch all in "my_cursor";
commit;
函数必须保持不变 - 它返回 refcursor 并接受 refcursor。
我想在 jOOQ 中执行它:
Routines.fooCursor(configuration, "Konrad", ____);
但我不知道在____ 中放什么,它需要Result<Record>。我试过类似的东西:
Result<Record> records = DSL.using(configuration).newResult();
但它也没有工作。
【问题讨论】:
标签: java postgresql jooq