NutzCN Logo
问答 postgresql11版的存储过程输出参数只支持INOUT类型。所以我用nutz调用的时候识别不了
发布于 1633天前 作者 xianghongwu 3184 次浏览 复制 上一个帖子 下一个帖子
标签:

这是我写的存储过程
CREATE OR REPLACE PROCEDURE "public"."pr_student_verify"(IN "p_school_id" varchar, IN "p_class_id" varchar, IN "p_student_code" varchar, INOUT "p_result_code" varchar)

然后调用
Sql sql = Sqls.create("call pr_student_verify(@p_school_id,@p_class_id,@p_student_code,@OUTp_result_code)");
//sql.setCallback(Sqls.callback.entities());
sql.setEntity(dao.getEntity(Testaaa.class));
sql.params().set("p_school_id", "680873162103066624"); // 设置入参
sql.params().set("p_class_id", "680874050016251904"); // 设置入参
sql.params().set("p_student_code", "10186csxxyx0010001"); // 设置入参
sql.params().set("OUTp_result_code", Types.VARCHAR);// 设置出参类型,注意,必须加OUT开头
dao.execute(sql);
Record re = sql.getOutParams();

然后报错
Caused by: org.postgresql.util.PSQLException: 这个 statement 未宣告 OUT 参数,使用 { ?= call ... } 宣告一个。
at org.postgresql.jdbc.PgCallableStatement.registerOutParameter(PgCallableStatement.java:205)
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.registerOutParameter(HikariProxyCallableStatement.java)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runExec(NutDaoExecutor.java:148)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:68)
... 90 common frames omitted

CREATE OR REPLACE PROCEDURE "public"."pr_student_verify"(IN "p_school_id" varchar, IN "p_class_id" varchar, IN "p_student_code" varchar, INOUT "p_result_code" varchar)
CREATE OR REPLACE PROCEDURE "public"."pr_student_verify"(IN "p_school_id" varchar, IN "p_class_id" varchar, IN "p_student_code" varchar, INOUT "p_result_code" varchar)
4 回复

sql语句写 @p_result_code, java代码写OUTp_result_code

sql写成这样?
CREATE OR REPLACE PROCEDURE "public"."pr_student_verify"(IN "p_school_id" varchar, IN "p_class_id" varchar, IN "p_student_code" varchar, INOUT "@p_result_code" varchar)

Sql sql = Sqls.create("call pr_student_verify(@p_school_id,@p_class_id,@p_student_code,@p_result_code)");
 sql.params().set("OUTp_result_code", Types.VARCHAR);// 设置出参类型,注意,必须加OUT开头

文档写了的

添加回复
请先登陆
回到顶部