Mysql 오류.. BIGINT UNSIGNED value is out of range in '(sstart@1 - 1)' 채택완료
mysql 에서 새로 생성한 함수 strip_tags 를 사용하려고 하면
1690 - BIGINT UNSIGNED value is out of range in '(sstart@1 - 1)'
라는 오류가 나옵니다.
SELECT strip_tags('
을 실행하면 정상적으로 결과물이 나옵니다.
하지만
SELECT strip_tags(wr_content) as stripped_text from g5_write_notice;
위의 구문을 실행하면 오류 메시지가 뜹니다... ㅠㅠ
이상한 것은 어제까지는 위의 구문이 잘 실행이 됐다는 것인데요....
혹시 해결방법 아시면 알려주시면 정말 감사하겠습니다...ㅠㅠ
생성한 함수 입니다.
delimiter || DROP FUNCTION IF EXISTS strip_tags|| CREATE FUNCTION strip_tags( x longtext) RETURNS longtext LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA BEGIN DECLARE sstart INT UNSIGNED; DECLARE ends INT UNSIGNED; IF x IS NOT NULL THEN SET sstart = LOCATE('<', x, 1); REPEAT SET ends = LOCATE('>', x, sstart); SET x = CONCAT(SUBSTRING( x, 1 ,sstart -1) ,SUBSTRING(x, ends +1 )) ; SET sstart = LOCATE('<', x, 1); UNTIL sstart < 1 END REPEAT; END IF; return x; END; || delimiter ; 출처: https://webee.tistory.com/entry/Mysql-%EC%97%90%EC%84%9C-HTML-%ED%83%9C%EA%B7%B8-%EC%82%AD%EC%A0%9C-%ED%95%A8%EC%88%98striptags">https://webee.tistory.com/entry/Mysql-에서-HTML-태그-삭제-함수striptags [Red Roof Garage]
답변 1개
CREATE FUNCTION `strip_tags`($str text) RETURNS text
BEGIN
DECLARE $start, $end INT DEFAULT 1;
LOOP
SET $start = LOCATE("<", $str, $start);
IF (!$start) THEN RETURN $str; END IF;
SET $end = LOCATE(">", $str, $start);
IF (!$end) THEN SET $end = $start; END IF;
SET $str = INSERT($str, $start, $end - $start + 1, "");
END LOOP;
END;
mysql> select strip_tags('hello wo<>rld <again<.');
+----------------------------------------------------------------------+
| strip_tags('hello wo<>rld <again<.') |
+----------------------------------------------------------------------+
| hello world again. |
+----------------------------------------------------------------------+
1 row in set
아니면
SELECT PREG_REPLACE('#<[^>]+>#',' ',cell) FROM table;
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인