【发布时间】:2018-03-29 11:49:34
【问题描述】:
所以我有一个 oracle functiion,例如:function unbind (ids in id_table)。它需要一组 id 来对我的数据库执行一些更新。
问题是如何运行我的函数以执行更新操作? 我已经尝试过的:
1.Query query = getSession().createSQLQuery("call UNBIND(:ids)");
query.setParameter("ids", myIds);
query.executeUpdate();
但我得到 ora-06576 不是有效的函数或过程名称
Query query = getSession().createSQLQuery("execute UNBIND(:ids)"); query.setParameter("ids", myIds); query.executeUpdate();
以 ora-00900 无效的 sql 语句结束
Long [] myArray = movedIds.toArray(new Long[movedIds.size()]); Boolean result = getSession().doReturningWork(new ReturningWork<Boolean>() { @Override public Boolean execute(Connection connection) throws SQLException { CallableStatement callableStatement = connection.prepareCall("{ ? = call UNBIND(:ids)"); callableStatement.registerOutParameter(1, Types.INTEGER); callableStatement.setArray(2, connection.createArrayOf("id_table", myArray)); callableStatement.execute(); return !(callableStatement.getInt(1) == 0); } });
以 java.sql.sqlfeaturenotsupportedexception 不支持的功能结束
应用程序通过 jboss 连接到数据库,所以我想这可能是 p 中的问题。 3?
-
SELECT UNBIND( id_table (6271789) ) FROM DUAL不起作用,因为我的函数执行更新...
还有其他方法可以运行直接从 java 代码中获取数组作为参数的函数吗?
【问题讨论】:
-
可以参考这个:jsumon.wordpress.com/2009/12/27/… 确保UBIND函数与连接数据库的用户空间存在相同的用户空间。