我写了触发器来检查客户是否有任何被暂停的帐户。如果是,他将无法创建新帐户,但是当我尝试插入时,插入仍然通过。有人可以帮我吗?
CREATE OR REPLACE TRIGGER SuspendedAccount
BEFORE INSERT ON ACCOUNT
FOR EACH ROW
DECLARE
varIsProblemAccount Int;
BEGIN
SELECT COUNT(*) INTO varIsProblemAccount
FROM ACCOUNT
WHERE CUSTID = :new.custID
AND ACCSTATUS = 'Suspended';
IF (varIsProblemAccount >= 1) THEN
DBMS_OUTPUT.PUT_LINE('*************************************************');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE(' Transaction canceled. ');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE(' Refer customer to the manager immediately. ');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('**************************************************');
RETURN;
END;
ELSIF (varIsProblemAccount = 0) THEN
BEGIN
DBMS_OUTPUT.PUT_LINE('*************************************************');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE(' Transaction completed. ');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE(' Thank the customer for their business. ');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('**************************************************');
END;
END IF;
END;
抱歉,我尝试更改为 0,因为它永远不能为“NULL”,但它仍然不起作用