Insert more than 22 fields using jooq dsl

Viewed 140

I want to insert more that 22 fields using dsl context.


 val dslContext: DSLContext = DSL.using(
    DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres?user=postgres&password=postgres"),
    SQLDialect.POSTGRES,
    jooqSettings)


 dslContext
        .insertInto(
          table,
          table.field1,
          table.field2,
          table.field3,
          table.field4,
          table.field5,
          table.field6,
          table.field7,
          table.field8,
          table.field9,
          table.field10,
        )
        .values(
          fields(0),
          fields(1),
          fields(2),
          fields(3),
          fields(4),
          fields(5),
          fields(6),
          fields(7),
          fields(8),
          fields(9)
        )
        .execute()

I want to insert more than 22 field but the constructor allows max 22 fileds. Is it possible to insert 22 fields??

1 Answers

The insertInto method can accept as many fields as you want (it has specific overloads up to 22 fields and a more generic vararg version that will accept 23 or more fields). So just keep adding your fields in the example you showed and it should work fine.

Related