0

トリガーをテーブルにアタッチした後、テーブルに値を挿入する際に問題が発生しました。トリガーは次のとおりです。

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.

よろしくお願いします!

4

1 に答える 1

3

これが問題だと思います:

 (Select email from Celebrity) <> N.followed_email

サブクエリはおそらく複数の行を返すため、スカラー演算子<>は機能しません。その条件を次のように言い換える必要があります。

WHEN ((Select COUNT(email) from Celebrity WHERE email = N.followed_email) = 0) ...
于 2012-06-01T19:30:09.353 に答える