我正在尝试在 PL/SQL 中创建一个插入前触发器,这将防止将空数据插入到表行中。(强制执行非空条件并防止插入数字或特殊字符的触发器。
这是我创建的表。
CREATE TABLE CUSTOMER
(
CUSTOMER_ID INTEGER
, CUST_FORENAME VARCHAR2(50) NOT NULL
, CUST_SURNAME VARCHAR2(50) NOT NULL
, GENDER CHAR(1)
, EMAIL_ADDRESS VARCHAR2(30) NOT NULL
, CONSTRAINT CUSTOMER_PK PRIMARY KEY (CUSTOMER_ID)
ENABLE
);
还有我创建的触发器。
create or replace
TRIGGER CUS_MAND before insert OR update on CUSTOMER
begin
CASE
WHEN :NEW.CUST_FORENAME = NULL
THEN DBMS_OUTPUT.PUT_LINE ('Please enter customer forename.');
WHEN :NEW.CUST_SURNAME = NULL
THEN DBMS_OUTPUT.PUT_LINE ('Please enter customer surname.');
WHEN :NEW.EMAIL_ADDRESS = NULL
THEN DBMS_OUTPUT.PUT_LINE ('Please enter customer email address.');
END CASE;
END;
但是这个触发器没有成功。有人可以为我解决问题吗?