我想为 Sybase 创建一个触发器,但它显示一个错误。
我要做的是,当对[student]
表进行删除操作时,检查 [account] 上是否有与学生相关的记录,如果有,则引发异常。
Sybase 似乎缺乏支持。他们的官员似乎没有人来参观。
*CREATE TRIGGER AccountChecker
BEFORE DELETE ON student
REFERENCING OLD AS old_student
FOR EACH ROW
BEGIN
DECLARE @acc CHAR(4);
DECLARE @acc_not_null EXCEPTION FOR SQLSTATE '99999';
SELECT @acc=account.account_number FROM account
WHERE account.student_id = old_student.student_id;
IF @acc IS NOT NULL
BEGIN
SIGNAL acc_not_null
END
END*