私は次のように選択を実行しようとしています:
def queries = [
[
paramQuey: "",
mainQuery: "SELECT * FROM SOME_TABLE"
],
[
paramQuey: "SELECT SOME_COLUMN AS COUNT FROM A_TABLE WHERE SOMETHING=3",
mainQuery: "SELECT * FROM OTHER_TABLE WHERE ROWNUM<:COUNT"
]
]
queries.each {
def params = [:]
if(!it.paramQuery.isEmpty()) {
params = sql.firstRow(it.paramQuery)
}
sql.eachRow(mainQuery, params) { //<--here's my problem
//do something
}
}
ただし、プログラムはスローします
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: groovy.sql.Sql.eachRow() is applicable for argument types: (java.lang.String, java.util.LinkedHashMap, MyClass$_execute_closure4) values: [SELECT * FROM SOME_TABLE, [:], MyClass$_execute_closure4@b3600d]
Possible solutions: eachRow(java.lang.String, groovy.lang.Closure), eachRow(java.lang.String, groovy.lang.Closure, groovy.lang.Closure), eachRow(java.lang.String, java.util.List, groovy.lang.Closure), eachRow(groovy.lang.GString, groovy.lang.Closure), eachRow(groovy.lang.GString, groovy.lang.Closure, groovy.lang.Closure), eachRow(java.lang.String, int, int, groovy.lang.Closure)
これは、名前付きパラメーターで eachRow を処理する方法がないことを明確に示しています。ただし、http: //groovy.codehaus.org/api/groovy/sql/Sql.htmlによると:
void eachRow(java.lang.String sql, java.util.Map params, Closure closure)
void eachRow(java.lang.String sql, java.util.Map params, Closure metaClosure, Closure rowClosure)
void eachRow(java.lang.String sql, java.util.Map map, Closure metaClosure, int offset, int maxRows, Closure rowClosure)
void eachRow(java.lang.String sql, java.util.Map params, int offset, int maxRows, Closure closure)
void eachRow(java.util.Map params, java.lang.String sql, Closure closure)
void eachRow(java.util.Map params, java.lang.String sql, Closure metaClosure, Closure rowClosure)
void eachRow(java.util.Map map, java.lang.String sql, Closure metaClosure, int offset, int maxRows, Closure rowClosure)
void eachRow(java.util.Map params, java.lang.String sql, int offset, int maxRows, Closure closure)
何が間違っているのか、eachRow で名前付きパラメーターをどのように処理すればよいのか疑問に思います。