after update trigger in mysql on same column

Posted by Shanky11 under Others on 8/28/2012 | Points: 10 | Views : 1700 | Status : [Member] | Replies : 1
create trigger trg_updt
after update on product
for each row
begin
update product set total=price+vat;
end;
table name=product
pid pname price vat total
1 ball 50 25 75
2 bat 85 15 100
i want when i run ---------update product set vat=20 where pid=2;
question.......it should automatically update total by trigger




Responses

Posted by: Nkkppp on: 8/28/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Shanky11,

Below is the trigger code for update on product table

create trigger Trg_Product_Update on product for update

as
begin
set nocount on
declare @vat int,@price int,@pid int
select @vat=vat,@price=price,@pid=pid from inserted
update product set total=@price+@vat where @pid=pid
end



Prathap, if this helps please login to Mark As Answer.

Regards,
Prathap.


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response