1. Explanation:
This is a custom mysq error that is reported at run time
function of 2.Mysql:
CREATE FUNCTION ' getclassname ' (classId INTEGER)
RETURNS varchar (CHARSET) UTF8
Deterministic
BEGIN
DECLARE cName VARCHAR () DEFAULT ';
SELECT ' name ' into the CName from class where cid=classid;
return cName;
End;
3. Analysis:
The meaning of the error is that this function is defined in the first line of CNAME this field is given the wrong string value: ' \xe4\xb8\xad\xe6\x96\x87 '
In fact, the value of the variable in the function received is inconsistent with its definition, but why does the varchar type disagree?
And then carefully check that it is assigned to the value inside must have Chinese inside, so the problem lies in Chinese, to solve this problem need to let CNAME this variable can receive Chinese only, so the above CNAME statement modified as follows:
CREATE FUNCTION ' Newproc ' (classId INTEGER)
RETURNS varchar (CHARSET) UTF8
Deterministic
BEGIN
DECLARE cName VARCHAR (m) CHARSET UTF8 DEFAULT ";
SELECT ' name ' into the CName from class where cid=classid;
return cName;
End;
is to specify the encoding format after the declaration CNAME: CHARSET UTF8
Run this function again, and the result will not be an error in Chinese.