groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GroovyBeginner <>
Subject Oracle Insert Data from one table to another table using Groovy
Date Tue, 26 Jul 2016 06:46:11 GMT
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

View raw message