开发者

Why groovy sql remove schema name from SQL queries?

开发者 https://www.devze.com 2023-01-12 21:47 出处:网络
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:

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.


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 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消