The notation $row is for use inside a string (called string interpolation).

Try changing your sql.executeInsert line to:

        sql.executeInsert "INSERT INTO A (ID, Name) VALUES ($row.ID,$row.Name)"


From:        GroovyBeginner <>
Date:        07/26/2016 02:46 AM
Subject:        Oracle Insert Data from one table to another table using Groovy

I have a requirement of inserting the data from table A into table B and am
using Oracle database. My condition is am going to insert only those records
which are not present in table B and am facing an issue of retrieving the
current row column values. Here is the code am trying.

   import groovy.sql.Sql;
   import java.sql.ResultSet;
   import java.util.Properties;
   sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:XE","username",
"password", "oracle.jdbc.driver.OracleDriver")
       sql.query("select ID, NAME from A where ID not in (select id from
B)") {
      row-> while( {
       sql.executeInsert "INSERT INTO A (ID, Name) VALUES ("+$row.ID"+,+"

and am facing issue `No such property: $row`. Kindly suggest me where am
going wrong and also is there any better approach of doing this in terms of
security and performance.

View this message in context:
Sent from the Groovy Dev mailing list archive at

NOTICE from Ab Initio: This email (including any attachments) may contain information that is subject to confidentiality obligations or is legally privileged, and sender does not waive confidentiality or privilege. If received in error, please notify the sender, delete this email, and make no further use, disclosure, or distribution.