stored procedure and trigger MySQL lost data -
first let me explain system: have 2 equal databases on 2 systems every 15 minutes new data of several tables synchronized.
for compare last primary key of first database last on second. every new data inserted via insert-statement in second database. data volume @ least 200 500 datasets. severs databases connected via internet.
the problem: on second databases have calculate value out of 2 values different tables , write in third db. wrote stored procedure , call trigger on 1 of tables.
but table trigger stores less data equivalent on first server. think runtime of stored procedure causes data loss. why? on test system works in productive process not.
another curiosity actual primary key of databases (auto increment integer) same. second db contains less data.
create definer=`root`@`%` procedure `calcsigma`(in `val1` double(10,2), in `ident` varchar(20), in `id` int(11), in `ts` datetime) begin declare phi, theta, sigma double default 0; if ident='x_theta' set theta = val1; set phi = (select val x_phi sensors_id = id , hour( timediff( ts, ts_rised))='0' , minute( timediff( ts, ts_rised))='0' order ts_rised desc limit 1); end if; if theta<>0 && phi<>0 if theta >= 0 set sigma =(((phi/100)*(288.68*pow(1.098+(theta/100),8.02)))/(461.5*(theta+273.15))); elseif theta < 0 set sigma =(((phi/100)*(4.689*pow(1.486+(theta/100),12.3)))/(461.5*(theta+273.15))); end if; insert x_sigma (ts_rised, val, sensors_id) values (ts, sigma, id); end if; end
Comments
Post a Comment