Hi Lukas,
I implememened a ExecuteListener as you recommended and the insert 
statements now find their way into the database :-)

I had to find out which tables actually have a identity column: 

select COLUMN_NAME, TABLE_NAMEfrom INFORMATION_SCHEMA.COLUMNSwhere TABLE_SCHEMA 
= 'dbo'and COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 
1order by TABLE_NAME


and than check ob the sql statement whether it is a insert or not:

if (ctx.configuration().data("prepend-identity-insert") != null && 
 ctx.sql().toLowerCase().contains("insert into")) {
            Matcher matcher = tablePattern.matcher(ctx.sql());
            while (matcher.find()) {
                String tableName = matcher.group(2).trim();
                if (idTables.contains(tableName)) {
                    ctx.sql("SET IDENTITY_INSERT " + tableName + "  ON " + 
ctx.sql());
                }
            }

        }

Maybe there is a better way to do this. 

BTW: Wouldn't it be better to have batch insert support for the csv and 
json loaders?

Thanks for your help!
Johannes



-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to