question about triggers
Date: 12 Oct 1994 13:46:23 GMT
Message-ID: <37gpbf$3ec_at_news-rocq.inria.fr>
I am a beginner in writing triggers with Oracle and I have a simple question. I'll use a short example: Suppose I have a table T with attribute a1 and a2. What I want to do is the following : each time a tuple is inserted with a NULL value for attribute a1, set it to (say) 10.
My problem is : a row trigger like
CREATE TRIGGER Set_attribute
AFTER INSERT ON T1
FOR EACH ROW
WHEN ( new.a1 = NULL )
(
UPDATE T1
SET a1 = 10;
)
should be rejected because I attempt to modify a mutating table , right ? (Furthermore it is ambiguous since I don't know if it updates only the inserted tuples or some other tuples as well)
CREATE TRIGGER Set_attribute
AFTER INSERT ON T1
FOR EACH STATEMENT
(
UPDATE T1
SET a1 = 10
WHERE a1 = NULL ;
)
Thanks in advance for any help,
Dimitri Tombroff Received on Wed Oct 12 1994 - 14:46:23 CET