groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Durham <david.durham...@gmail.com>
Subject Re: Batch Insert with Sequence?
Date Tue, 01 Dec 2015 04:38:25 GMT
I think your insertString will have something like "insert into
myTable (...) values (mysequence.nextval, ?,?,?)"

On Mon, Nov 30, 2015 at 9:33 AM, Daniel Price <danprice303@gmail.com> wrote:
> 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