You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Jitendra Kharche <Ji...@geometricsoftware.com> on 2006/07/24 13:08:50 UTC

ERROR 22001

Hi,
 
I am using Derby that is embedded in Websphere App Server Community
Edition.
I get the following error 
ERROR 22001: A truncation error was encountered trying to shrink VARCHAR

Can anybody explain about this and how can i remove it.
 
Regards,
Jitendra

RE: ERROR 22001

Posted by Michael Segel <ms...@segel.com>.
The .trim() method of a String will truncate the ending white space.
You can do a substring with a starting position of 0 and the MAX value of a
VARCHAR (which should be a constant somewhere).

This should ensure that the string is truncated and will fit.

> -----Original Message-----
> From: Kristian.Waagan@Sun.COM [mailto:Kristian.Waagan@Sun.COM]
> Sent: Monday, July 24, 2006 6:26 AM
> To: Derby Discussion
> Subject: Re: ERROR 22001
> 
> Jitendra Kharche wrote:
> > Hi,
> >
> > I am using Derby that is embedded in Websphere App Server Community
> Edition.
> > I get the following error
> > ERROR 22001: A truncation error was encountered trying to shrink VARCHAR
> > Can anybody explain about this and how can i remove it.
> 
> Hello Jitendra,
> 
> To me it looks like the data that is inserted into Derby is too large
> (ie. the string is too long). The maximum size of VARCHAR in Derby is
> 32672 characters. It might also be that the column is defined to have a
> smaller maximum length.
> 
> As for truncation, only trailing whitespace can be truncated.
> 
> You could check the length of your data and the maximum length of the
> column it is inserted into.
> If the data is too long, you can increase the size of your VARCHAR column.
> If you need to store larger amounts of texts, you might have to use CLOB
> instead.
> 
> You also have LONG VARCHAR. It is the same as VARCHAR, but you don't
> need to specify a maximum length when you create the table. It can hold
>   a maximum of 32700 characters.
> 
> 
> 
> 
> Regards,
> --
> Kristian
> 
> >
> > Regards,
> > Jitendra




Re: ERROR 22001

Posted by Kristian Waagan <Kr...@Sun.COM>.
Jitendra Kharche wrote:
> Hi,
>  
> I am using Derby that is embedded in Websphere App Server Community Edition.
> I get the following error
> ERROR 22001: A truncation error was encountered trying to shrink VARCHAR
> Can anybody explain about this and how can i remove it.

Hello Jitendra,

To me it looks like the data that is inserted into Derby is too large 
(ie. the string is too long). The maximum size of VARCHAR in Derby is 
32672 characters. It might also be that the column is defined to have a 
smaller maximum length.

As for truncation, only trailing whitespace can be truncated.

You could check the length of your data and the maximum length of the 
column it is inserted into.
If the data is too long, you can increase the size of your VARCHAR column.
If you need to store larger amounts of texts, you might have to use CLOB 
instead.

You also have LONG VARCHAR. It is the same as VARCHAR, but you don't 
need to specify a maximum length when you create the table. It can hold 
  a maximum of 32700 characters.




Regards,
-- 
Kristian

>  
> Regards,
> Jitendra