tom_ wrote:
Hello Kristian,
this is a good idea, truncating by java before writing by SQL. Yes, varchar
removes trailing blanks, though it would help if it would cut larger values
instead of not writing them. If you have a look at the error message it
shows that he tries to cut the value to the limit but has an exception.
Yes, it is trying to cut, but is not allowed to do so because the data
to be cut consists on non-blanks.
There is no support for allowing Derby to truncate "real data". You
could add a feature request to Jira[1], but since there are relatively
simple work arounds available, I don't know if it will get much traction
in the community.
cheers,
--
Kristian
[1] https://issues.apache.org/jira/browse/DERBY
Thank you for helping
Tom
Kristian Waagan-4 wrote:
tom_ wrote:
When defining a datatype with varchar(128) and providing an input with
more
than 128 characters the value is not inserted in the database. There is
an
error message "error when trying to cut to 128 characters" (translated
from
german).
Hello Tom,
Only trailing white space will be truncated by Derby. I *think* this is
according to the SQL standard, but I haven't checked this (anyone?).
Two options would be to either extract a substring from the value in
Java (i.e. before you call PreparedStatement.setString), or rely on
exception handling to detect and handle the problem.
regards,
--
Kristian
I could encrease the maximum length but when there are a lot of values
with
shorter length and only very few with longer length than 128 this would
decrease the speed of search operations ...