Mysql 오류.. BIGINT UNSIGNED value is out of range in '(sstart@1 - 1)'

Mysql 오류.. BIGINT UNSIGNED value is out of range in '(sstart@1 - 1)'

QA

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('<div style="font-size:12px">This is a body area</div>') as stripped_text;

을 실행하면 정상적으로 결과물이 나옵니다.

하지만

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-에서-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('<span>hel<b>lo <a href="world">wo<>rld</a> <<x>again<.');
+----------------------------------------------------------------------+
| strip_tags('<span>hel<b>lo <a href="world">wo<>rld</a> <<x>again<.') |
+----------------------------------------------------------------------+
| hello world again.                                                   |
+----------------------------------------------------------------------+
1 row in set

 

 

아니면

 

 

SELECT PREG_REPLACE('#<[^>]+>#',' ',cell) FROM table;

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 1,506
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT