Technology

I'm speaking at...

I teach and consult for

Spring, Hibernate, Grails, Rails and Maven training from the experts!
Training Calendar

Roo in Action

Soon in print!

Spring Roo in Action
MEAP Available Now!

Author, Roo in Action - in MEAP now
Manning Book Forum
My Roo Blog Entries
Srini Penchikala InfoQ

Twittery!

@krimple
@techcast
@gdickens
@RooInAction

I host the
Chariot TechCast

« Calling PostgreSQL Stored Procedures from Grails - Optimized Service class | Main | Calling PostgreSQL Stored Procedures from Grails - Part 3, SqlFunction »
Friday
Mar262010

Calling PostgreSQL Stored Procedures from Grails - Part 4 - Groovy SQL

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...

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>