Problem with Encode and Decode Functions

Problem with Encode and Decode Functions

am 15.10.2002 19:21:09 von Ross Rannells

--Boundary_(ID_VzDz6dzUtHHmLIfLhWhgTg)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: quoted-printable

I am having problem with the encode and decode functions in MySQL. When
the second argument is a call to the char function, they return an
error, yet they work fine when a string is the second argument. I am
using MySQL version 3.23.33 on Solaris 5.7.
=20
An example of the problem from MySQL command line interface follows:
=20
select encode("Password","key");
+--------------------------+
| encode("Password","key") |
+--------------------------+
| m=E9LC..É£ |
+--------------------------+
=20
select decode("Password","key");
+--------------------------+
| decode("Password","key") |
+--------------------------+
| ß}=AA lÉÛ |
+--------------------------+
=20
select encode(char(80,97,115,115,119,111,114,100),"key");
+---------------------------------------------------+
| encode(char(80,97,115,115,119,111,114,100),"key") |
+---------------------------------------------------+
| m=E9LC..É£ |
+---------------------------------------------------+
=20
=20
select decode(char(80,97,115,115,119,111,114,100),"key");
+---------------------------------------------------+
| decode(char(80,97,115,115,119,111,114,100),"key") |
+---------------------------------------------------+
| ß}=AA lÉÛ |
+---------------------------------------------------+
=20
select encode("Password",char(107,101,121));
ERROR 1064: You have an error in your SQL syntax near
'char(107,101,121))' at line 1
=20
select decode("Password",char(107,101,121));
ERROR 1064: You have an error in your SQL syntax near
'char(107,101,121))' at line 1
=20
select encode(char(80,97,115,115,119,111,114,100),char(107,101,121) );
ERROR 1064: You have an error in your SQL syntax near
'char(107,101,121))' at line 1
=20
select decode(char(80,97,115,115,119,111,114,100),char(107,101,121) );
ERROR 1064: You have an error in your SQL syntax near
'char(107,101,121))' at line 1
=20
Ross Rannells
Senior Software Developer
Donnell Systems
(574) 232-3784, ext 213
=20
=20
How-To-Repeat:
select encode("Password","key");
select decode("Password","key");
select encode(char(80,97,115,115,119,111,114,100),"key");
select decode(char(80,97,115,115,119,111,114,100),"key");
select encode("Password",char(107,101,121));
select decode("Password",char(107,101,121));
select encode(char(80,97,115,115,119,111,114,100),char(107,101,121) );
select decode(char(80,97,115,115,119,111,114,100),char(107,101,121) );
=20

--Boundary_(ID_VzDz6dzUtHHmLIfLhWhgTg)--

Re: Problem with Encode and Decode Functions

am 15.10.2002 20:05:44 von Sinisa Milivojevic

Ross Rannells writes:
> I am having problem with the encode and decode functions in MySQL. When
> the second argument is a call to the char function, they return an
> error, yet they work fine when a string is the second argument. I am
> using MySQL version 3.23.33 on Solaris 5.7.
>

[skip]

Hi!

Yes, the above is expected behaviour.

ENCODE() and DECODE() functions are designed to work with text strings
only in second parameter.

This should be documented better, though ..

--
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread12738@lists.mysql.com
To unsubscribe, e-mail