MySQL存储过程参数中文乱码

1.在命令控制台通过命令设置编码

查看mysql的编码格式  show variables like 'character_set_%';
设置 编码格式 set names 'utf8';

2.明确参数编码


/******************************************
@description         set style number
@author               luke
@date               2012-09-25
***************************************/
DROP PROCEDURE IF EXISTS sp_SetStyle;

CREATE PROCEDURE sp_SetStyle(IN style_num VARCHAR(100) CHARACTER SET utf8 , IN  flight_id int) -- , IN  flight_id int)--
 BEGIN
   
    DECLARE hasInProduction bool;       
    DECLARE state INT;
    DECLARE sql_header  VARCHAR(300) CHARACTER SET utf8 ;
        DECLARE sql_tailor  VARCHAR(300) CHARACTER SET utf8 ;
        SET sql_header='SELECT @state:=fp.state AS \'状态\' FROM tb_flight_process fp,tb_batch b,tb_style s  WHERE fp.batch_id=b.batch_id AND b.style_id=s.style_id AND s.style_num=';
        -- SELECT (fp.state INTO @state) , @state FROM tb_flight_process fp,tb_batch b,tb_style s  WHERE fp.batch_id=b.batch_id AND b.style_id=s.style_id AND s.style_num=';
        SET sql_tailor='  AND fp.incept_state=1 AND fp.flight_id=537';
        SET @sql = CONCAT(sql_header,'N\'',style_num, '\'', sql_tailor);

       -- SET style_num='AZ风衣#09';
    
     -- SELECT @state AS s0;
         -- SELECT @sql;
         prepare stem FROM @sql;
         execute stem;
       
      SELECT @state AS s1;
        -- SELECT state,'AZ风衣#09';
         -- SELECT @state;   

END

call sp_SetStyle('AZ风衣#09', 537);

 

修改了编码后,有时会出现显示中文乱码,重启Navicat即可。

 

 

你可能感兴趣的:(数据库)