Grails使用输出参数调用存储过程

时间:2013-05-10 05:43:41

标签: oracle grails stored-procedures

我之前成功调用了存储过程,但没有输出参数,现在有这样的新程序。

var returntype number; 
begin 
 IZMST_PKG_SOLO_GENERATE_SQL.pro_get_row_cnt(1,181,:returntype); 
end;

当我将此程序称为同伴错误消息时: 错误

org.apache.commons.dbcp.DelegatingCallableStatement with address:
    "oracle.jdbc.driver.OracleCallableStatementWrapper@52d0d407" is
    closed.. Stacktrace follows: java.sql.SQLException:
    org.apache.commons.dbcp.DelegatingCallableStatement with address:
    "oracle.jdbc.driver.OracleCallableStatementWrapper@52d0d407" is
    closed.     at
    org.apache.commons.dbcp.DelegatingStatement.checkOpen(DelegatingStatement.java:137)
        at
org.apache.commons.dbcp.DelegatingCallableStatement.getObject(DelegatingCallableStatement.java:144)
    at
com.pg.izoom.de.ExtractManagementController$$EO5PWcUR.addExtract(ExtractManagementController.groovy:74)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
像这样的代码:

Connection conn = dataSource.getConnection()
            Sql sql = new Sql(conn)
            //int test  = sql.call("",)
            sql.call'BEGIN  IZMST_PKG_SOLO_GENERATE_SQL.pro_get_row_cnt(?,?,?); END;',[1L,qryId,Sql.resultSet(OracleTypes.NUMBER)],{dwells-> 
                println dwells
            }

任何熟悉此事的人都可以帮助我吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果我理解,您的返回类型为number,因此您可以直接使用Sql.NUMERIC

sql.call '{call IZMST_PKG_SOLO_GENERATE_SQL.pro_get_row_cnt(?,?,?) }',[1L, qryId, Sql.NUMERIC],{ dwells -> 
  println dwells
}