mbayloon mbayloon - 2 months ago 27x
Groovy Question

How can I call a stored procedure using groovy?

  1. how can i call a stored procedure using groovy?

  2. how can i create a stored procedure from grails project (as domain classes to create data base)?


An example of calling a FullName stored procedure which takes a param ('Sam' in the example) and returns a VARCHAR."{? = call FullName(?)}", [Sql.VARCHAR, 'Sam']) { name ->
    assert name == 'Sam Pullara'

The same example again but with a GString variation:

def first = 'Sam'"{$Sql.VARCHAR = call FullName($first)}") { name ->
    assert name == 'Sam Pullara'

Here is an example of a stored procedure with an out parameter: '{call Hemisphere(?, ?, ?)}', ['Guillaume', 'Laforge', Sql.VARCHAR], { dwells ->
    println dwells // => Northern Hemisphere

Refer this.