function 예제
select FUNC_TITLE_HISTORY('0|:|2001|:|110342|:|110378','en')
drop function FUNC_TITLE_HISTORY;
CREATE FUNCTION FUNC_TITLE_HISTORY (_val varchar(256), _lang varchar(64)) RETURNS varchar(1024)
begin
DECLARE var1 VARCHAR(1024) DEFAULT 'home';
DECLARE var2 VARCHAR(256) DEFAULT '';
DECLARE var3 VARCHAR(256) DEFAULT '';
DECLARE var4 VARCHAR(256) DEFAULT '';
DECLARE var5 VARCHAR(256) DEFAULT '';
select if(SPLIT_STRING(_val, '|:|',2)='','',(select MENU_NM from comtnmenuinfo_global where MENU_NO=SPLIT_STRING(_val, '|:|',2) and lang_id=_lang)) into var2;
select if(SPLIT_STRING(_val, '|:|',3)='','',(select MENU_NM from comtnmenuinfo_global where MENU_NO=SPLIT_STRING(_val, '|:|',3) and lang_id=_lang)) into var3;
select if(SPLIT_STRING(_val, '|:|',4)='','',(select MENU_NM from comtnmenuinfo_global where MENU_NO=SPLIT_STRING(_val, '|:|',4) and lang_id=_lang)) into var4;
select if(SPLIT_STRING(_val, '|:|',5)='','',(select MENU_NM from comtnmenuinfo_global where MENU_NO=SPLIT_STRING(_val, '|:|',5) and lang_id=_lang)) into var5;
select if(var2='',var1, concat_ws('|:|',var1,var2)) into var1;
select if(var3='',var1, concat_ws('|:|',var1,var3)) into var1;
select if(var4='',var1, concat_ws('|:|',var1,var4)) into var1;
select if(var5='',var1, concat_ws('|:|',var1,var5)) into var1;
return var1;
end
'DB > MYSQL' 카테고리의 다른 글
PORT 변경 (0) | 2019.03.04 |
---|---|
MYSQL 일자별 백업 (0) | 2019.03.04 |
MYSQL 암복호화 (0) | 2019.03.04 |
mysql -u root -p (0) | 2019.03.04 |
DB 백업 및 복원 (0) | 2019.03.04 |