Thanks for replying... I am not using JOOQ code generator.

request.getStatus()  returns State which is an Java enum and has the
following values.

PENDING,CREATE_COMPLETE,DELETE_IN_PROGRESS,DELETED,DELETE_FAILED

The following query doesnt work too

create.insertInto(table("stack_info"))
        .set(field(name("id")), request.getStackId())
        .set(field(name("user_name")), request.getUserName())
        .set(field(name("time_created")), request.getTimeCreated())
        .set(field(name("product")), request.getProduct().toString())
        .set(field(name("label")), request.getLabel())
        .set(field(name("instance_type")), request.getInstanceType())
        .set(field(name("status")), request.getStatus().toString())
        .execute();


However, I am able to insert rows in the DB using SQL workbench which
happily accepts String values for enum columns..

Thanks,
Ganesh

On Mon, Oct 1, 2018 at 10:13 PM Rob Sargent <[email protected]> wrote:

> What data type does request.getStatus() return? and are you using the jOOQ
> code generator?
>
> On Oct 1, 2018, at 10:26 PM, [email protected] wrote:
>
> I upgraded JOOQ to version 3.11. And used the following code.
>
> create.insertInto(table("stack_info"))
>         .set(field(name("id")), request.getStackId())
>         .set(field(name("user_name")), request.getUserName())
>         .set(field(name("time_created")), request.getTimeCreated())
>         .set(field(name("product")), request.getProduct().toString())
>         .set(field(name("label")), request.getLabel())
>         .set(field(name("instance_type")), request.getInstanceType())
>         .set(field(name("status")), request.getStatus())
>         .execute();
>
>
>
> I still get the following error:-
>
> Caused by: org.postgresql.util.PSQLException: ERROR: column "status" is of
> type stack_status but expression is of type character varying
>   Hint: You will need to rewrite or cast the expression.
>   Position: 163
>
>
> Can someone please help.
>
> Thanks,
> Ganesh
>
> On Monday, October 1, 2018 at 8:59:59 PM UTC-7, Ramaseshan Ganesh wrote:
>>
>> Hi,
>>
>> I am trying to insert a row into the table using the query below using
>> JOOQ.
>>
>>
>> create.insertInto(
>>         table("stack_info"),
>>         fieldByName("id"),
>>         fieldByName("user_name"),
>>         fieldByName("time_created"),
>>         fieldByName("product"),
>>         fieldByName("label"),
>>         fieldByName("instance_type"),
>>         fieldByName("status"))
>>         .values(
>>                 request.getStackId(),
>>                 request.getUserName(),
>>                 request.getTimeCreated(),
>>                 request.getProduct().toString(),
>>                 request.getLabel(),
>>                 request.getInstanceType(),
>>                 request.getStatus().toString()
>>         ).execute();
>>
>>
>>
>>
>> Running the above query, I get the following error.
>>
>> Caused by: org.jooq.exception.DataAccessException: SQL [insert into
>> stack_info ("id", "user_name", "time_created", "product", "label",
>> "instance_type", "status") values (?, ?, cast(? as timestamp), ?, ?, ?,
>> ?)]; ERROR: column "status" is of type stack_status but expression is of
>> type character varying
>>
>>   Hint: You will need to rewrite or cast the expression.
>>
>>   Position: 163
>>
>>
>> stack_status is defined as an ENUM in the DB. It has the following
>> values:-
>>
>> stack_status :
>> PENDING,CREATE_COMPLETE,DELETE_IN_PROGRESS,DELETED,DELETE_FAILED
>>
>> Any pointers, how to fix this ?
>> Thanks,
>> Ganesh
>>
>
> --
> 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/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "jOOQ User Group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jooq-user/K3sT3F5mnM0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/d/optout.

Reply via email to