Search code examples
sqlgroovyresultset

Groovy SQL Multiple ResultSets


I am calling a stored procedure from my Groovy code. The stored proc looks like this

SELECT * FROM blahblahblah

SELECT * FROM suchAndsuch

So basically, two SELECT statements and therefore two ResultSets.

sql.eachRow("dbo.testing 'param1'"){ rs ->
    println rs
}

This works fine for a single ResultSet. How can I get the second one (or an arbitrary number of ResultSets for that matter).


Solution

  • You would need callWithAllRows() or its variant.

    The return type of this method is List<List<GroovyRowResult>>.

    Use this when calling a stored procedure that utilizes both output parameters and returns multiple ResultSets.