Hello Pay,

Length, Precision and Scale in cast expressions are only going to be
supported in jOOQ 3.0. For now, I suggest you use the substring()
function:
http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#substring(org.jooq.Field,
int, int)

Here are some other Postgres String functions, many of which are
supported by jOOQ in some way:
http://www.postgresql.org/docs/9.2/static/functions-string.html

Of course, if you want to explicitly use casting, you can write your
own plain SQL for that:

create.insertInto(TEST2)
      .values(Factory.field("?::varchar(5)", String.class, "too long"))
      .execute();

Hope this helps

Cheers
Lukas

2013/1/8 Pay Liu <[email protected]>:
> Hi all,
>
> The size of my string column  is too small, and I would like to truncation
> my too long string to be fit the size of column.
>
> I know how to do it in SQL, as below doc:
> http://www.postgresql.org/docs/9.1/interactive/datatype-character.html
>
> But I can't find how to do in JOOQ.
>
> Very thanks!
>
>
> -Pay
>
> INSERT INTO test2 VALUES ('too long');
> ERROR:  value too long for type character varying(5)
> INSERT INTO test2 VALUES ('too long'::varchar(5)); -- explicit truncation

Reply via email to