sql - in mysql trigger.. how to use insert into and update query -
i have product_price_log table. updated ever new price updated in product_price table.
i using trigger:
drop trigger if exists product_update; delimiter $$ create trigger product_update before update on w3xab_virtuemart_product_prices each row begin declare virtuemart_product_id int; declare old_product_price decimal(15,5) default 0; declare new_product_price decimal(15,5) default 0; declare price_update_date date; if (new.product_price <> old.product_price) insert product_price_log (virtuemart_product_id,old_product_price, new_product_price, price_update_date) values (new.virtuemart_product_id, old.product_price, new.product_price, curdate()) on duplicate key update old_product_price = values(old.product_price), new_product_price = values(new.product_price), price_update_date = curdate(); end if; end$$ delimiter ;
now no error..but update not working when try update price... insert working
i set virtuemart_product_id primay key dont know whats going m totally stuck @ point... cant understand why not updating..
i don't think can values(curdate())
since isn't column name. try price_update_date=curdate()
Comments
Post a Comment