Friday
Mar262010
Calling PostgreSQL Stored Procedures from Grails - Part 4 - Groovy SQL
Friday, March 26, 2010 at 4:35PM Every time I say "Groovy SQL" I feel there should be an implied comma. Like, "Groovy, SQL!"
Groovy SQL is a simple API for calling SQL Statements in the vein of JdbcTemplate, but it's totally, um... Groovy. Here is the very tiny snippet of code to call our Stored Procedure with Groovy SQL:
def sumBookSalesByBookIdGSQL(int bookId) {
def gsql = new groovy.sql.Sql(dataSource)
def results = gsql.rows("select salesByBookId(${bookId})")
results["salesbybookid"][0]
}
There. Isn't that, just, Groovy, SQL? The results returned seem to be a map of results, with each one having a list of values. I think for simple Stored Functions such as the one in Part 1, I say it's Groovy SQL FTW...
tagged
Chariot Solutions,
chariot-news in
Groovy/Grails,
PostgreSQL
Chariot Solutions,
chariot-news in
Groovy/Grails,
PostgreSQL 


Reader Comments