我在PostgreSQL中有一个存储过程,该存储过程返回一个 refcursor ,我想使用Spring Jdbc SimpleJdbcCall对其进行调用。
过程代码如下:
CREATE OR REPLACE FUNCTION show_emps() RETURNS refcursor AS $$
DECLARE
ref refcursor; -- Declare a cursor variable
BEGIN
OPEN ref FOR SELECT emp_id, first_name FROM emp; -- Open a cursor
RETURN ref;
END;
$$ LANGUAGE plpgsql;
谁能帮助我使用代码来调用此过程并使用SimpleJdbcCall类获取其数据。 我正在使用以下代码进行通话,但无法正常工作:
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate);
jdbcCall.withProcedureName("show_emps");
Map<String, Object> result = jdbcCall.execute();