我在插入触发器后将值插入表中时遇到了问题。 触发器如下:
CREATE TRIGGER trig
AFTER INSERT ON Follows
REFERENCING NEW as N
FOR EACH row
WHEN ((Select email from Celebrity) <> N.followed_email)
UPDATE followSuggestion SET followSuggestion.Suggested_follower = N.followed_email, followSuggestion.Suggested_followee = N.follower_email
;
插入代码如下:
INSERT INTO follows
VALUES('Michael_Phelps@uss.net','Michael_Phelps@uss.net');
错误如下
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES
INTO statement is more than one row. SQLSTATE=21000
SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row.
先谢谢你了!
答案 0 :(得分:3)
我认为这是问题所在:
(Select email from Celebrity) <> N.followed_email
子查询可能会返回多行,因此标量运算符&lt;&gt;不管用。 您必须将该条件改为:
WHEN ((Select COUNT(email) from Celebrity WHERE email = N.followed_email) = 0) ...