Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL++ - Programming with the C++ API to MySQL
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
ODBC - ODBC with the MySQL Connector/ODBC driver
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
Reversing a string

Reversing a string

2006-08-28       - By Nils Drews

 Back
Reply:     1     2  

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

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/maxdb?unsub=mysql@(protected)