我编写了自己的第一个trigger里面有错误,找不到原因
自己写了第一个trigger,但是编译无法通过。代码如下:
CREATE OR REPLACE TRIGGER biud_sp_info
BEFORE INSERT OR UPDATE ON sp_info
FOR EACH ROW
BEGIN
IF NEW.sp_code IN (SELECT sp_code FROM sp_info) THEN
Error(-200001, ‘You must make sure THE sp_code DISTINCT.’);
END IF;
END;
------解决方案--------------------‘You must make sure THE sp_code DISTINCT.’
是中文字符。改成:
'You must make sure THE sp_code DISTINCT. '
即可
------解决方案--------------------NEW.sp_code前漏了冒号“:”