• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Once again on triggers

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic