반응형
생년월일 (열 중 하나)이 미래인 경우 삽입을 방지하는 트리거를 만들고 싶습니다. 나는 이것을 가지고있다:
CREATE TRIGGER foo
BEFORE INSERT ON table
FOR EACH ROW
BEGIN
IF NEW.birthdate > CURRENT_DATE()
THEN
//How do I prevent the insert right here???
END IF;
END;
if 문 내에서 삽입을 취소하려면 어떻게해야합니까?
해결 방법
MySQL의 현재에는 지원이 없습니다. implementation of triggers to voluntarily throw an exception and abort the statement that spawned the 방아쇠.
내가 찾은 해결 방법은 a BEFORE trigger to set one of the not-NULL columns in the table to NULL, thus violating its NOT NULL constraint. This causes the statement that spawned the trigger to be 중단되었습니다.
참조 페이지 https://stackoverflow.com/questions/2981930
반응형
'MySql' 카테고리의 다른 글
MySQL 자바를 사용하여 데이터베이스에 날짜 시간 삽입 (0) | 2020.11.22 |
---|---|
MySQL Laravel의 열 증가 (0) | 2020.11.22 |
MySQL 트리거 / 저장 프로 시저에서 쉘 스크립트 / 명령 실행 (0) | 2020.11.22 |
MySQL INDEX를 사용하는 이유와 위치-장단점 (0) | 2020.11.22 |
MySQL T-SQL을 MySQL로 변환 (0) | 2020.11.22 |
댓글