我已经完成了代码,它在scala中执行任何查询都是完美的,除非我的查询必须使用两次相同的参数。数据库版本是12,oracle jar是ojdbc6,我写这段代码才能执行查询
def executeQuery(locale: String, query: String, input: Map[String, String], output: List[String]): Vector[Map[String, Any]] = {
var connection: Connection = null;
val properties = ConnectionLoader.getConnectionProperties(locale);
try {
connection = getDBConnection(properties);
val statement = connection prepareCall (query)
if (null != input)
for ((k, v) <- input) {
statement.setObject(k, v)
}
for (k <- output) {
statement.registerOutParameter(k, OracleTypes.INTEGER)
}
val resultSet = statement.executeQuery();
realize(resultSet);
} catch {
case e => throw e;
} finally {
if (null != connection)
connection.close();
}
}
我的查询是
SELECT COUNT (1)
FROM ORDERS
WHERE ORDER_ID = :P_ORDER_ID AND STATUS_ID = 4
这个查询工作正常,但我在执行时遇到错误
SELECT COUNT (1)
FROM ORDERS
WHERE ORDER_ID = :P_ORDER_ID AND STATUS_ID = 4 and :P_ORDER_ID=9
无论这个非逻辑查询我都会收到此错误
执行异常[[SQLException:在索引:: 2处缺少IN或OUT参数]] 我已经搜索了所有内容,但我没有结果请建议