kaushik
kaushik

Reputation: 2492

JOOQ concatenation

I have a query like this:

Result<?> result = create.select(CONSUMER.CONS_ID_NO,
                                             CONSUMER.CONS_NAME,
                                             concat(CONSUMER.AREA_CODE, "/", CONSUMER.CONS_NO, "/", CONSUMER.CAT_CODE).as("ConsNo"),
                                             CONSUMER.ARREARS)
                                            .from(CONSUMER)
                                            .fetch();

I wrote this according to the JOOQ Manual, but I am getting an error that says:

The method concat(String...) in the type Factory is not applicable for the arguments (TableField, String, TableField, String, TableField)

I am using JOOQ-3.

Upvotes: 11

Views: 5604

Answers (1)

longhua
longhua

Reputation: 4242

It seems that the sample in the manual doesn't work. However, you can convert a string to Filed via org.jooq.impl.Factory.val.

    Record result = create.select(
            concat(AUTHOR.FIRST_NAME, val(" "), AUTHOR.LAST_NAME).as("Full Name")
    ).from(AUTHOR).fetchAny();

Please refer to this email from Lukas Eder for details

Upvotes: 17

Related Questions