PL/SQL (MOSC)

MOSC Banner

reference column value in table level trigger

edited Feb 10, 2010 9:09AM in PL/SQL (MOSC) 15 commentsAnswered
 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;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center