db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew McIntyre" <mcintyr...@gmail.com>
Subject Re: auto truncation of varchar
Date Wed, 21 Feb 2007 04:49:20 GMT
On 2/20/07, Amir Michail <amichail@gmail.com> wrote:
> Hi,
> Is there a way to get derby to silently truncate varchar columns?

Could you use the substr function to accomplish this?


simple example:

create table foo (v varchar(5));
insert into foo values (substr('too long', 1, 5));

also works with prepared statements, here's an example from inside ij:

prepare ins1 as 'insert into foo values (substr(?, 1, 5))';
execute ins1 using 'values (''another'')';

ij> select * from foo;
too l

hope that helps,

View raw message