在设置好mysql同步后,运行存储过程测试,
存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `prodForTran_proc`(in new_uid bigint, in new_pay_orderID varchar(255), in new_pid int, in new_sid int, in new_pct int, in new_price double, in new_pay_type int, in new_app_id int, in new_itemID int, in new_status bit,out flags int) begin DECLARE txn_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN SET txn_error=1; END; start transaction; INSERT INTO shop_userproduct VALUES(new_uid,new_pid,new_sid,new_pct,current_timestamp(),new_status,new_app_id) ON DUPLICATE KEY UPDATE p_count=p_count+new_pct ,create_time=current_timestamp(); insert into shop_order values(null,new_pay_orderID,new_uid,new_pay_type,new_price,new_pid,new_pct,current_timestamp(),new_status); update shop_item set sales = sales + new_pct where itemID=new_itemID; if txn_error=1 then rollback; select 0 into flags; insert into shop_order values(null,new_pay_orderID,new_uid,new_pay_type,new_price,new_pid,new_pct,current_timestamp(),false); else COMMIT; select 1 into flags; end if; end
注意其中有in new_status bit 这个参数,当同步运行到这里时,就会报错,不认传进来的‘true‘或者’false‘,同步出错,但是如果不在存储过程里执行,而是在控制台执行插入或者更新’true‘或者’false‘ ,则可以进行同步,所以解决办法为将存储过程中的’true‘或者’false‘值,用1或者0来代替,就不会出现错误