Creating a trigger statement
drop trigger if exists update_asset;
drop trigger if exists insert_asset;
drop trigger if exists process_asset;
delimiter |
create procedure process_asset_calc
(
in name varchar(50),
in cost decimal(20,2),
in life int(11),
in whenacquired date,
inout Months_Depreciated int(11),
inout Accumulated_Value double(2,0),
in residual_value double(2,0),
inout Monthly_Depreciation double(2,0))
BEGIN
set Months_Depreciated = (YEAR( NOW() * 12 + Month(NOW())) - (YEAR(whenacquired) * 12) +Month(whenacquired);
set Monthly_Depreciation = (cost / life) * residual_value;
set Accumulated_Value = Months_Depreciated * Monthly_Depreciation;
END|
CREATE TRIGGER `update_asset`
before update ON `asset`
for each row
BEGIN
call process_asset_calc(new.name,new.cost,new.life,new.residual_value,new.whenacquired,new.Accumulated_Value,new.Monthly_Depreciation, new.Months_Depreciated);
END|
CREATE TRIGGER `insert_asset`
before insert ON `asset`
for each row
BEGIN
call process_asset_calc(new.name,new.cost,new.life,new.residual_value,new.whenacquired,new.Accumulated_Value,new.Monthly_Depreciation, new.Months_Depreciated);
END|
delimiter ;
when i run this code it gives me this error "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
set Monthly_Depreciation = (cost / life) * residual_value;
set Accumulated_Val' at line 12". and i can't seem to get what it means. Please any help clearing this error will be appreciated. thanks