On 26.07.2016 08:46, GroovyBeginner wrote:
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(row.next()) { sql.executeInsert "INSERT INTO A (ID, Name) VALUES ("+$row.ID"+,+" $row.Name+")" } } 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.
my sql is rusty, but: Insert into B select ID, NAME from A where ID not in (select id from B); bye Jochen