• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parse out parmeters from groovy sql

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am calling a stored procedure using groovy sql to fetch the output result set and output parameters. Below is my high level code. When i am trying to print my output parameter,I am not getting the output as a readable object. Any thoughts on how can I parse the output parameter.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the output you get from the two printlns?
 
Rajesh Santhanakrishnan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For params1 , I getting the value as groovy.sql.Sql$7@3ec4d8f6
For params2 , I am getting the below exception

 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For params1 , I getting the value as groovy.sql.Sql$7@3ec4d8f6


This means that the object groovy.sql.Sql does not have its own toString() method and it is using Object's (all classes inherit from Object).

For params2 , I am getting the below exception


This means that you're calling the method get() on an array, and there is no such method.

It will help to know exactly what you're trying to do, in English (that is, not in "programmer talk").
 
Rajesh Santhanakrishnan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response Knute.
The stored procedure is returning the value 5 in the output parameter . I am trying to get the value from my groovy dao layer.
I tried different parsing options for the params , but nothing seems to work out
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I believe you would use rs inside the for-loop. Or am I missing something?
 
Rajesh Santhanakrishnan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My stored procedure, gives output both as result set and in output parameter.
Yes, I am using rs inside the for loop to get the result set output , which is working fine.
To get the output parameter values, I am not able to get it.
Note:When I print input parameter values using .value , it works fine.
 
Rajesh Santhanakrishnan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got a solution. It looks like the groovy version 2.4.6 does not support both output parms and resultset.
The fix is available in 2.4.7 with callwithRows() method.

https://objectpartners.com/2014/01/24/simpler-stored-procedures-with-groovy/
http://docs.groovy-lang.org/latest/html/gapi/groovy/sql/Sql.html

Thanks knute for the help provided so far
reply
    Bookmark Topic Watch Topic
  • New Topic