在java获取存储过程的返回值

阿程 2012-07-26 01:25:21
这是存储过程!
 PROCEDURE train_type_d(trainTypeId int,
rtn out int)
is
v_count number;
begin
select count(*) into v_count from TRAIN_TYPE where UP_TRAIN_TYPE_ID= trainTypeId;
if v_count>0 then
rtn := 0;
else
delete TRAIN_TYPE where TRAIN_TYPE_ID = trainTypeId;
rtn := 1;
end if;
end;


执行后 返回rtn 类型是int的
java执行存储代码(例如)
this.sysBiz.delTrainType(id);

怎样在java中获取rtn的值?
THX!
...全文
169 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiyiwan 2012-07-26
  • 打赏
  • 举报
回复
那么你需要检查delTrainType内部是如何实现的,为什么传入参数只有一个id而没有传出参数。
下面一篇文章可参考之。

http://blog.csdn.net/jiandanfeng2/article/details/6609623
阿程 2012-07-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

CallableStatement c=conn.prepareCall("{call getsum(?,?)}");
c.setInt(1,100);
c.registerOutParameter(2,java.sql.Types.INTEGER);
c.execute();
System.out.println(c.getInt(2));
[/Quote]

我用的是ibatis 不需要您的那些代码 就是this.sysBiz.delTrainType(id);直接就执行了,是封装的方法,怎样获得?
shiyiwan 2012-07-26
  • 打赏
  • 举报
回复
CallableStatement c=conn.prepareCall("{call getsum(?,?)}");
c.setInt(1,100);
c.registerOutParameter(2,java.sql.Types.INTEGER);
c.execute();
System.out.println(c.getInt(2));
阿程 2012-07-26
  • 打赏
  • 举报
回复
没人会吗!·--·!

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧