database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 29858 게시물 읽기
No. 29858
함수로 데이타 불러올때 한글이 깨집니다..
작성자
김영범(bumworld)
작성일
2010-12-03 01:19
조회수
9,154

데이타 베이스 새로 설치후에 발생하는 문제 입니다.

 

현재 데이타 자체는 한글이 제대로 들어가 있구요..

 

인코딩 타입은 utf-8 입니다.

 

그냥 함수는 제가 작성한 조건에 따라 데이타 불러오는 함수구요.

 

그런데 작성한 함수를 통해서 데이타를 가져올시에만 한글이 깨지는 현상이 발생합니다.

 

원래는 한글이 깨지던 함수는 아니었습니다.

 

안에 쿼리만 따로 빼서 돌려보면 한글은 잘 나옵니다.

 

정말 신기하게 함수를 통해서만 나오면 한글이 깨지네요..

 

도움 부탁드립니다.

 

centos에 yum으로 설치했구요. mysql 버전은 5.0.77-log 입니다.

 

 

create function get_waving_user(v_talking_no integer) returns varchar(50)

begin

declare v_waving_user varchar(50) default '';

select

case a.cnt when 1 then

    CONCAT(b.nick_name, '님')

else

    CONCAT(b.nick_name, '님 외 ', a.cnt)

   end into v_waving_user

from

(

select user_no, count(1) as cnt from tb_waving where talking_no = v_talking_no group by talking_no

   ) a

   , tb_user b

where

a.user_no = b.user_no

;

return v_waving_user;

 

이 글에 대한 댓글이 총 1건 있습니다.

함수 끝에 리턴 변수에 대한 캐릭터셋을 설정해보세요.

CREATE FUNCTION ... RETURNS VARCHAR(50) CHARACTER SET UTF8

레퍼런스에는 다음과 같이 나와있습니다. (출처:http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html)

For character data types, if there is a CHARACTER SET attribute in the declaration, the specified character set and its default collation are used. If there is no such attribute, as of MySQL 5.0.25, the database character set and collation that are in effect at the time the server loads the routine into the routine cache are used. (These are given by the values of the character_set_database and collation_database system variables.) If the database character set or collation change while the routine is in the cache, routine execution is unaffected by the change until the next time the server reloads the routine into the cache. The COLLATE attribute is not supported. (This includes use of BINARY, which in this context specifies the binary collation of the character set.)

박현우(lqez)님이 2010-12-06 11:16에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
29862MySql 메모리 설정에 관련 질문 입니다. [6]
염진근
2010-12-07
15880
29861mysql 간단한 질문! [1]
nmj
2010-12-07
6952
29859mysql 업로드 같은 값이면 하나만 남게... [1]
허점강
2010-12-03
7704
29858함수로 데이타 불러올때 한글이 깨집니다.. [1]
김영범
2010-12-03
9154
29857dump받은 파일이 약 3기가인데요 [2]
이정호
2010-12-02
7320
29856mysql 새로 설치시 password 함수의 구현 방식이 다른가요? [2]
김영범
2010-12-02
7202
29854두개 테이블 값 비교 left join [1]
join
2010-11-30
8069
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.025초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다