的最後,我有一個Grails服務這Groovy的僞腳本更新:常規的SQL更新遊標 - 沒有承諾直到光標
sql.eachRow("""
select id, col1, col2
from mytab
where col1 is null or col2 is null
"""
){
... some code to produce c1, c2 here ...
sql.execute("""
update mytab
set col1 = ${c1}, col2 = ${c2}
where id = it.id
""")
}
的問題是,更新承諾:只在eachRow循環結束DB 。我想要在sql.execute調用中準確提交更新。
我試過sql.eachRow前右側插入 sql.resultSetConcurrency = GroovyResultSet.CONCUR_UPDATABLE ,但更新只繼續循環結束後提交。 也在sql.execute()之後立即調用sql.commit(),但又沒有成功。
Sql連接來自DBCP Tomcat數據源,訪問Oracle 8.1.7數據庫。
謝謝!
由於http://groovy.codehaus.org/api/groovy/sql/Sql.html#commit(),commit()被忽略,因爲sql是從數據源創建的 – tmanolatos
我不得不把 **靜態transactional = false ** 在我的服務中。 現在它按預期工作... 請參閱http://grails.org/doc/latest/guide/single.html#services – tmanolatos