我试图在Oracle中调用存储的函数。 此函数不仅具有返回值,还具有OUT参数。 我是Groovy的新手,但有很多数据库经验。 如何检索返回的实际值。 这是我的示例调用...假设我已经有一个很好的数据库连接。
我有一个具有以下签名的商店功能:
GET_JOB(job_id IN VARCHAR2, max_sal OUT INTEGER) RETURNS VARCHAR2我在groovy中打电话:
def result = sql.call("{? = call get_job(?, ?)}", [Sql.VARCHAR, 'TE', Sql.NUMERIC])这似乎运行没有错误,但我不知道如何检索返回值和OUT参数(第二个参数)
I am trying to make a call to a stored function in Oracle. This function not only has a return value but also has an OUT parameter. I am relatively new to Groovy but have a lot of database experience. How do I retrieve the actual values returned. Here is my sample call...assume I already have a good database connection.
I have a store function with the following signature:
GET_JOB(job_id IN VARCHAR2, max_sal OUT INTEGER) RETURNS VARCHAR2I make the call in groovy:
def result = sql.call("{? = call get_job(?, ?)}", [Sql.VARCHAR, 'TE', Sql.NUMERIC])This seems to run with no errors, but I am unclear as to how to retrieve the return value and the OUT parameter (second parameter)
最满意答案
该方法的int Sql.call(String, List)形式不处理输出参数。 您可以使用void Sql.call(String, List, Closure) 。
sql.call("{? = call get_job(?, ?)}", [Sql.VARCHAR, 'TE', Sql.NUMERIC]) { maxSal -> // do whatever with maxSal }注意:如果获得存储过程的返回值而不是out参数,请尝试: sql.call(...) { ret, maxSal -> }
The int Sql.call(String, List) form of the method doesn't handle output parameters. You can use void Sql.call(String, List, Closure) instead.
sql.call("{? = call get_job(?, ?)}", [Sql.VARCHAR, 'TE', Sql.NUMERIC]) { maxSal -> // do whatever with maxSal }Note: If you get the return value of the stored procedure instead of the out parameter, try: sql.call(...) { ret, maxSal -> }
更多推荐
发布评论