如何在Spring中调用存储过程来读取返回值和输出参数

如何在Spring中调用存储过程来读取返回值和输出参数

本文介绍了如何在Spring中调用存储过程来读取返回值和输出参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,它返回一个整数以及一个 VARCHAR 类型的输出参数.

I have a stored procedure which returns an Integer as well as an Out Parameter which is of type VARCHAR.

我使用的是 Spring 2.5.6 并且无法找到同时读取返回值和输出参数的方法.

I am using Spring 2.5.6 and unable to find a way to read the return value as well as Out Parameter at the same time.

SimpleJdbcCall.executeFunction(..) 具有读取存储过程返回值的功能,但没有读取输出参数的功能.

SimpleJdbcCall.executeFunction(..) have a facility to read the stored procedure return value but no facility for Out Parameter.

SimpleJdbcCall.execute(..) 可以读出参数.

SimpleJdbcCall.execute(..) can read Out parameters.

Spring 中还有其他方法可以完成上述操作.

There are other ways also in Spring to do the above.

我是否在 Spring 中遗漏了一些可以同时读取的东西,或者存储过程是错误的,因为它应该只使用 Out Param 或 Return Value 而不是同时使用两者?

Am I missing something in Spring which can read both at the same time or the stored procedure is wrong as it should only use Out Param or Return Value but not both at same time?

推荐答案

如果你使用的是 Spring 2.5X,我相信 SimpleJdbcCall#withReturnValue() 指定你想要返回要包含在返回结果中的值.我不确定地图中的条目将被键入什么,但我会尝试一下.

If you are using Spring 2.5X, I believe that SimpleJdbcCall#withReturnValue() specifies that you want the return value to be included in the return results. I'm not sure what the entry will be keyed to in the Map, but I'd try that out.

这篇关于如何在Spring中调用存储过程来读取返回值和输出参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 07:48