MySQL Forums
Forum List  »  MySQL Administrator

Re: updating current values using trigger
Posted by: ram nathan
Date: March 13, 2009 12:29AM

CREATE TRIGGER `tracking_duplicate_update` AFTER UPDATE on `table1`
FOR EACH ROW BEGIN
declare assignedtime1 date;
declare status1 varchar(10);

select status into status1 from `table1` where ID=new.ID;
select assigntime into assignedtime1 from table2 where Id=new.ID;

update table2 set assigntime=new.date_mod where id=new.ID;//here updating the new value

if (status1 = 'assign' ) and isnull(assignedtime1) then

update table2 set assigntime=new.date_mod where id=new.ID;//here its updating the old value
end if;

END$$

DELIMITER ;

Options: ReplyQuote


Subject
Written By
Posted
Re: updating current values using trigger
March 13, 2009 12:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.