sqlgroovygroovy-sql

Groovy Sql Execute Statement won't accept closures


I have a statement:

sqlInstance.execute(executeString){
                    dummy, realList->
                    debug("Real LIst: "+realList)

                    }

which fails with 'Invalid column type'

But:

def bool = sqlInstance.execute(executeString)

works. If I print bool, it prints as 'true'.

For reference:

executeString = "select distinct channel_id from guide_sched"

For some reason, the closure isn't working for the execute method in groovy's Sql, although I've checked the documentation and it's supposed to.


Solution

  • It looks like the first environment I was testing on ran Groovy 2.4 and the second runs Groovy 2.1. The execute statement I was using didn't exist until after 2.1

    Instead, I used the .rows() function to return a GroovyRowResult which I parsed for the information I needed, instead of accessing it directly in the .execute() closure.