CREATE OR REPLACE TRIGGER "MY_TRIGGER2"
BEFORE INSERT ON "FILM"
FOR EACH ROW
BEGIN
IF :NEW.RATING = 'G'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST - .10
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Recommended for all audiences';
END IF;
IF :NEW.RATING = 'PG'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST + .20
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Parental guidance for young viewers';
END IF;
IF :NEW.RATING = 'PG-13'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST + .20
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Parental guidance for young viewers';
END IF;
IF :NEW.RATING = 'R'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST + .60
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Recommnded for mature audiences';
END IF;
IF :NEW.RATING = 'NC-17'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST + 1.0
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Mature audiences only';
END IF;
END;
/
我有这个,但concat部分抛出错误。 有什么建议吗?
答案 0 :(得分:1)
:NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Mature audiences only';
我在那个(或任何其他)concat
行的末尾(1)上看不到右括号。这几乎肯定是语法错误。
(1) 在分号之前,很明显。
答案 1 :(得分:1)
此代码:
IF :NEW.RATING = 'G'
THEN :NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST - .10
AND :NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Recommended for all audiences';
END IF;
很奇怪。除了缺少的人之外,不要使用AND
进行分配。所以:
IF :NEW.RATING = 'G' THEN
:NEW.REPLACEMENT_COST := :NEW.REPLACEMENT_COST - .10;
:NEW.DESCRIPTION := CONCAT(:NEW.DESCRIPTION, 'Recommended for all audiences');
END IF;
您需要修复其余代码。