Groovy GString issues

后端 未结 4 1837
后悔当初
后悔当初 2020-12-22 09:17

I\'m want use $ macro in groovy GString. When i\'m wrote this code

[\'cdata\',\'tdata\'].each { def sql = \"select * from $it_1\" }

i\'m ge

4条回答
  •  别那么骄傲
    2020-12-22 09:26

    Real answer was behind the question, so I'm sorry.
    Groovy SQL makes parameterized query from GString, so after I had defined GString

    def sql = "select * from ${it}_1";
    

    I passed it to Groovy SQL and when I tried to execute the query, the actual query was

    "select * from :?_1";
    

    Of cource this drives MSSQL crazy.
    Thanks to you all again, maybe someone will find this useful.

提交回复
热议问题