我使用触发器在使用MySQL数据库的php中插入null值期间生成错误消息。
这是触发器:
DELIMITER $$
USE `soap_account_add`$$
DROP TRIGGER /*!50032 IF EXISTS */ `soap_account_add_insert_trigger`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `soap_account_add_insert_trigger` BEFORE INSERT ON `soap_account_add_insert`
FOR EACH ROW BEGIN
IF (NEW.client_code IS NULL OR NEW.client_code = '') THEN
SET NEW='Error: Client Code can not be empty. ';
END IF;
IF (NEW.msisdn IS NULL OR NEW.msisdn = '') THEN
SET NEW='Error: MSISDN can not be empty. ';
END IF;
IF (NEW.account_ref IS NULL OR NEW.account_ref = '') THEN
SET NEW='Error: Account can not be empty. ';
END IF;
END;
$$
DELIMITER ;
以下是我要上传的文件格式:
client_code,account_ref,msisdn,msisdn_type
2161304,1013322512,01944689009,NK
2160417,1013318996,01944675008,NK
2202905,1013762565,,AX
2387742,,01982074930,NK
,1015732958,01982074930,NK
但是,我只收到一条错误消息:
Variable 'new' can't be set to the value of 'Error: MSISDN can not be empty.'
我没有收到另外两条错误消息。我的触发器脚本中有任何问题吗?