create or replace trigger insert_test_id
before insert on test
where(test.name='Ash')
begin
insert into test(s_no) values('def');
end
my table is
test
id integer
name varchar2(200)
s_no varchar2(250)
please tell me that what is the error in this trigger. I am not able to find out.
A quick glance at the online documentation would have told you that the conditional syntax is WHEN not WHERE.
You should also reference the column using the NEW keyword rather than the table name. And as Gary rightly points out, we can only apply the conditional clause for ROW LEVEL triggers:
The condition works too…
It even works for multiple rows….
So what’s the problem? This:
Of course I have cheated here, to generate the error. If both the test value and the substituted value are hard-coded the problem can be avoided. But if either is a lookup, then the risk of recursion is there.
If what you actually want to do is replace an input value rather insert an additional row you should use the simple assignment syntax posted by @Lukas.