IntelliJ Java IDE
The moose likes Oracle/OAS and the fly likes Once again on triggers Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "Once again on triggers" Watch "Once again on triggers" New topic
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.
 
IntelliJ Java IDE
 
subject: Once again on triggers
 
Threads others viewed
Trigger after transaction
Hibernate triggers
Getting error message - chapter 9 of ejb 3 in action using glassfish server 2.1
ORA-01403: no data found + Oracle + Trigger
view ddl for all triggers
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture