groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinko Srko─Ź <dinko.sr...@gmail.com>
Subject Re: Oracle Insert Data from one table to another table using Groovy
Date Tue, 26 Jul 2016 16:03:02 GMT
On 26 July 2016 at 15:47, GroovyBeginner <groovybeginner@gmail.com> wrote:
> I tried this and facing the following issue
>
> groovy.lang.MissingPropertyException: No such property: ID for class:
> oracle.jdbc.driver.OracleResultSetImpl

I'm only guessing here because I can't run the code at the moment and
I'd always avoided using `query` method, but I'd say that the reason
why there's no property `ID` is that you used `sql.query`, and so your
`row` value is just a Java's `ResultSet`, not Groovy's enhanced
version of it.

So, instead of using `query`:

  sql.query("select ID, ...") { row ->
      while (row.next()) {
          sql.executeInsert ...
      }
  }

try using `eachRow` method instead:

  sql.eachRow("select ID, ...") { row ->
      sql.executeInsert ...
  }

That way, instead of `ResultSet`, you get `GroovyResultSet`, which
shouldn't break on things like `row.ID`, and you don't have to use a
while loop because `eachRow` does the looping internally.

Cheers,
Dinko

PS
this topic is not really suited for the dev list, which is for the
development of Groovy itself. It should go to the users list. Please
see http://groovy-lang.org/mailing-lists.html

> Possible solutions: row
>
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)
>
>         at
> org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
>
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:291)
>
>         at ConsoleScript1$_run_closure1.doCall(ConsoleScript1:8)
>
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/Oracle-Insert-Data-from-one-table-to-another-table-using-Groovy-tp5734285p5734298.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.

Mime
View raw message