Result is probably being displayed as null because `forEach` method in fact returns `void`, which Groovy transforms into `null`, as it expects a method to actually return something.
As for nothing being inserted, perhaps there is nothing to insert (every ID in A is also in B)? Cheers, Dinko On 27 July 2016 at 12:57, GroovyBeginner <groovybegin...@gmail.com> wrote: > I have tried the following code now and seems to be nothing is being inserted > into the database table. I have executed the following code and the result > is displayed as null. > > 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.eachRow("select ID, NAME from A where ID not in (select id from B)") > { row-> > sql.executeInsert "INSERT INTO A (ID, Name) VALUES ($row.ID,$row.Name)" > } > > > > -- > View this message in context: > http://groovy.329449.n5.nabble.com/Oracle-Insert-Data-from-one-table-to-another-table-using-Groovy-tp5734285p5734303.html > Sent from the Groovy Dev mailing list archive at Nabble.com.