INSERT INTO test2 VALUES ('too long');
ERROR: value too long for type character varying(5)
INSERT INTO test2 VALUES ('too long'::varchar(5)); -- explicit truncationString fieldText = String.format("'%s'", text);
create.insertInto(TEST2)
.set(TEST2.B, Factory.substring(Factory.field(fieldText, String.class), 1, 5))
.set(...other....)
.execute();
BTW, I find the number 5 is a magic number. I try to get the column size from my JOOQ java code, but I can't.
Do I miss or there is no static variable from code generator?
ex: TEST2.B.getSize() ??
Thanks, Lukas.
-Pay
oh oh~ I know now, Lukas :)
And thanks for your hint, I need to avoid that SQL injection.
Have a goody ~
- Pay
create.insertInto(TEST2)
.set(TEST2.B, Factory.substring(Factory.inline(text, String.class), 1, 5))
.set(...other....)
.execute();