groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Price <danprice...@gmail.com>
Subject Batch Insert with Sequence?
Date Mon, 30 Nov 2015 15:33:53 GMT
Hi all.  I've been using Groovy to batch insert data into SQL Server, and
it works very well.  The syntax I've been using is:

//batch insert
int dbThrottle = 25000
db.withTransaction{
   def result = db.withBatch(dbThrottle, insertString){ ps ->
      output.each{
         ps.addBatch(it)
       }
   }
}

This code is used to insert data from list 'output' into my Sql Server DB.
The 'insertString' is just the typical insert statement dynamically derived
from the target table and columns.

I now have a need to use a sequence generator to populate one or more
columns in some tables.  I can do this by putting sequence numbers in a
list and inserting such sequence lists into my 'output' data list, but this
is very slow.  Is there a way I can include the 'NEXT VALUE FOR' sequence
query in the batch insert query so that it is evaluated during batch
insert?  Will this be any faster?

Thanks!
D

Mime
View raw message