Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger

Status
Not open for further replies.

Nsan

MIS
Apr 30, 2003
13
Can someone please tell me what I am doing wrong? I am trying to create a trigger that will convert a negative number to a positive number after an insert. This is how it would be done with Oracle..

Any help would be appreciated...

create or replace trigger <trigger name>
after insert
on <tablename>
for each row
when new.col < 0
declare
begin
:new.col := abs:)new.col);
end;
 
Hello,

You should be able to find an example in Books on Line. I would use the Columns_Updated() function in the trigger. Books ON Line describes how to do that.

Carla

Documentation: A Shaft of light into a Coded world
 
SQL server supports statement triggers only

Code:
create trigger sb_tr1
on sb
for insert as 
 update tb set col = abs(col)
  where tb_pk in (select tb_pk from inserted)
    and col < 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top