我是 PLSQL 的新手,我想创建一个触发器,在进行更新之前首先检查表中是否有记录。到目前为止我得到的代码是:
CREATE OR REPLACE TRIGGER table_bu
BEFORE UPDATE ON employee
FOR EACH ROW
DECLARE
v_employee_id:=employee.employee_ID%TYPE;
BEGIN
SELECT employee_id INTO v_employee_id FROM employee;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR (-20001,'data not found');
END;
如何创建一个触发器来检查表中是否存在记录,如果不存在则不允许更新。我的表结构是:
employee_id NUMBER
employee_name VARCHAR(20)
employee_salary NUMBER
...
谢谢