| Author |
Once again on triggers
|
Chhaya Dhanani
Ranch Hand
Joined: Apr 11, 2001
Posts: 70
|
|
hi all, i had earlier posted a query on triggers and was glad to receive a reply i now want to modify the trigger such that it is conditional assume: table struture is as follows 1)category varchar2(20) 2)name varchar2(20) 3)age number(2) the earlier reply gave me the below trigger: create trigger the_trigger_name before insert on the_table_name for each row begin :new.column := replace(:new.column,'-',''); end; / i want to modify the above such that the it replaces the "-" only for a particular category say if category="A" and name="abc_xyz", the trigger should fire and insert name as "abcxyz". how do i go about doing this. waiting for reply in anticipation... boss over my head..have a deadline help help Thanx in advance Chhaya
|
 |
Remar Uy
Ranch Hand
Joined: Mar 18, 2002
Posts: 35
|
|
Hi Chhaya, Try modifying; create trigger the_trigger_name before insert on the_table_name for each row when (new.category = 'some_value' and new.name = 'some_value') begin :new.column := replace(:new.column,'-',''); end; / or an IF statement: create trigger the_trigger_name before insert on the_table_name for each row begin if :new.category = ..... then :new.column := replace(:new.column,'-',''); end if; end; / Check this link for more info:Triggers hth.
|
 |
 |
|
|
subject: Once again on triggers
|
|
|