Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Help! Trouble with Triggers

Help! Trouble with Triggers

From: Matt Larson <matt_larson_at_jdedwards.com>
Date: 1997/12/18
Message-ID: <67bmsj$683$1@server1.incc.net>#1/1

I have a table that can only have a certain number of rows (let's say the max is two rows). I set up a trigger to count the entire table after each insert. The table is initially empty. I issue the same statements in TWO sessions.

insert into test values (1);
insert into test values (2);

After both sessions have completed these two lines, I issued a commit to each. Both commit and leave a total of 4 rows in the table.

How can I make a trigger that will prevent this from happening??

Please email answers to matt_larson_at_jdedwards.com Thanks

create or replace trigger trigger_test
AFTER INSERT on test
DECLARE
v_variable number;
BEGIN
select count(*) into v_variable from test; if v_variable > 2 then
raise_application_error(-20000,'Too many entries in table'); end if;
END trigger_test; Received on Thu Dec 18 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US