Nils Drews wrote ! 
> 
> Hello group,
> 
> i got a strange problem while implementing a function, which 
> reverses a 
> string. It is very simple, but only works for strings (VARCHAR) of a 
> maximum length of 38 chars. If a String is longer than that 
> it produces 
> the following error:
> 
> Error: com.sap.dbtech.jdbc.exceptions.DatabaseException: 
> [-2010] (at 8): 
> Assignment impossible, char value too long, SQL State: 22001, Error 
> Code: -2010
> 
> 
> The function is:
> 
> CREATE FUNCTION reverse(s VARCHAR) RETURNS VARCHAR AS
> VAR result VARCHAR(255); actualchar VARCHAR; indexRight INT;
>  
> IF s is NULL THEN RETURN NULL;
>  
> SET indexRight = LENGTH(s);
> SET result = '';
>  
> WHILE indexRight > 0 DO BEGIN
>     SET actualChar = SUBSTR(s, indexRight, 1);
>     SET indexRight = indexRight - 1;
>     SET result = result & actualChar;
> END;
> RETURN result;
> 
> 
> So i tested with:
> 
> SELECT inxmail_reverse('AAAAAAAAAAAAAAABBBBBBBBBBBBBBBCCCDDDDD') FROM 
> BWTABLES
> 
> if i add an E at the end of the string i get the error.
> 
> What am i doing wrong and where is that CHAR column the error 
> message is 
> complaining about ???
> 
> Thx in advance,
> 
> Nils Drews

This is a bug caused by the fact that the parameter s has an unknown
size at compilation time. 
As a workaround please substitute 's VARCHAR' by 's CHAR(255)'. This
actually does not change anything for you because you have a limit of
255 characters inside your code anyhow.

Best Regards,
Thomas 

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to