MYSQL CURSOR 塞入中文會變亂碼

edited 三月 2014 in 資料庫

您好:
若以下程式碼中, select cID,cName,cSex from students;
cName 是中文

但是 FETCH dept_csr INTO l_id,l_code1,l_code2; 後
撈出來 卻變為亂碼!

這該如何處理?
謝謝!
BEGIN

  DECLARE l_id          INT;
  DECLARE l_code1      CHAR(8);
  DECLARE l_code2      CHAR(2);
  DECLARE l_count      INT;
  DECLARE no_more_maps INT;
	

  DECLARE dept_csr CURSOR FOR
       select cID,cName,cSex from students;


  DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_maps=1;


  SET no_more_maps=0;


  OPEN dept_csr;
        dept_loop:REPEAT
           -- 用FETCH將cursor逐筆讀入
           FETCH dept_csr INTO l_id,l_code1,l_code2;
           IF no_more_maps=0 THEN
                SET l_count=l_count+1;
                select l_id,l_code1,l_code2;
           END IF;
        UNTIL no_more_maps
        END REPEAT dept_loop;
        CLOSE dept_csr;
        SET no_more_maps=0;
END
Sign In or Register to comment.