====== Functions & Procedures For Mysql, Mariadb ====== * description : 마리아DB, Mysql 유용한 사용자 정의 함수 모음 * author : 주레피 * email : dhan@repia.com * lastupdate : 2022-05-18 ===== Case Study ===== HTML 제거 SET GLOBAL log_bin_trust_function_creators=1; DROP FUNCTION IF EXISTS fnStripTags; DELIMITER | CREATE FUNCTION fnStripTags( Dirty varchar(4000) ) RETURNS varchar(4000) DETERMINISTIC BEGIN DECLARE iStart, iEnd, iLength int; WHILE Locate( '<', Dirty ) > 0 And Locate( '>', Dirty, Locate( '<', Dirty )) > 0 DO BEGIN SET iStart = Locate( '<', Dirty ), iEnd = Locate( '>', Dirty, Locate('<', Dirty )); SET iLength = ( iEnd - iStart) + 1; IF iLength > 0 THEN BEGIN SET Dirty = Insert( Dirty, iStart, iLength, ''); END; END IF; END; END WHILE; RETURN Dirty; END; | DELIMITER ; SELECT fnStripTags('this is a test, nothing more'); ===== Ref ===== * [[https://forums.mysql.com/read.php?52,177343,177985|Re: Removing HTML tags using mysql]] {{tag>주레피 마리아DB mariadb mysql 함수 프로시저}}