reference column value in table level trigger
Hi,
Is it possible to have a table level trigger that can reference a column.
What I need to do is to check the sum of a column after a update and fail the update if the sum exceeds certain limit.
CREATE TABLE test (name VARCHAR2(30), SIZE NUMBER);
CREATE OR REPLACE TRIGGER chk_8k
AFTER UPDATE ON test_trigger
DECLARE
v_size NUMBER; v_extra NUMBER;
BEGIN
SELECT Sum(size)) total_size, Sum(size) - 8000 extra INTO v_size, v_extra
FROM test
WHERE name = <current_value>;
IF v_size > 8000 THEN
Raise_Application_Error(-20001,'my error message');
END IF;
What I need to do is to check the sum of a column after a update and fail the update if the sum exceeds certain limit.
CREATE TABLE test (name VARCHAR2(30), SIZE NUMBER);
CREATE OR REPLACE TRIGGER chk_8k
AFTER UPDATE ON test_trigger
DECLARE
v_size NUMBER; v_extra NUMBER;
BEGIN
SELECT Sum(size)) total_size, Sum(size) - 8000 extra INTO v_size, v_extra
FROM test
WHERE name = <current_value>;
IF v_size > 8000 THEN
Raise_Application_Error(-20001,'my error message');
END IF;
0