postgresql - 如何使用 Spring SimpleJdbcCall 调用 PostgreSQL 存储过程并从返回的 refcursor 获取数据
问题描述
我在 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();
解决方案
推荐阅读
- bash - Shell独立设置环境变量的方式
- react-native - react native 中的默认 node_modules
- symfony - VueJS webpack 构建错误 SCSS 相关
- angular - 如何使用 HttpClient angular 4 正确过滤 json
- javascript - ng-options 未从 javascript 数组中提取
- c# - 如何通过分配新集合来更新多对多集合?
- protractor - 量角器选择元素 by.cssContainingText 找不到元素
- vba - 我的代码将所有工作簿合并到单独的工作表中。我需要将所有内容合并到一张同一张纸上
- algorithm - 气体混合算法
- html - 在移动浏览器上查看时显示“Double”的字体