tags:

views:

29

answers:

1

I need to execute this query:

 Select * from my_schema.table_within_schema 

Unfortunately groogy.sql.SQL is removing my_schema and executing a query without schema information:

 Select * from table_within_schema 

I wonder if it is possible to force groovy.sql.Sql to keep a schema name in the query.

Groovy: 1.7, Db: I use a jdbc driver that requires a schema name specified.

A: 

I haven't run into this situation yet but you can 'force' groovy to use a String query instead of a GString if you want to, below is a mysql jdbc example:

Sql sql = ...(the usual) 

def query = "SELECT * from `my_schema`.mytable" 

sql.eachRow( query.toString()  ) {
// do something 
}
Vinny
Hi, did you specify a db name creating a new instance of Sql object? Are you sure that you are using `my_schema` instead of a schema from your jdbc url (used in calling SQL.newInstance())?
Skarab