我创建了三个名为
的MySql表然后我创建了一个名为 purchase_data_mv_update 的存储过程,它会截断 mv_purchase_data 的数据 表格和插入表格 r_sisl_purpurchase 和 r_mil_pur 的值。 其脚本如下
DELIMITER //
CREATE PROCEDURE purchase_data_mv_update ()
BEGIN
TRUNCATE TABLE mv_purchase_data;
INSERT INTO mv_purchase_data
(unit_code, season_cntrl, ryot_code, purchy_number, mill_purchy, vrt_code,vgrp_code, token_date, token_time, gross_date, gross_time,
tare_date, tare_time, gross, tare, net, joona, amount, vehicle_code, society, tran_type, for_unit, token_type
)
SELECT
unitcode AS unit_code, season AS season_cntrl, ryot_code, s_purchy AS purchy_number, m_purchy AS mill_pur_no, vrt_Code, vgrp_code,
arr_date AS token_date, arr_time AS token_time, gross_date, gross_time, tran_date AS tare_date, TIME AS tare_time, gross, tare, net,
(gross-tare)joona, amount, p_mode MODE, soc_code, tran_type, CONCAT('0',SUBSTR(s_purchy,1,1)) forunit, '0' token_type
FROM r_sisl_purpurchase
UNION ALL
SELECT a.unit_code, a.season_cntrl, a.m_grower ryot_code, a.m_ind_no, a.mill_pur_no, a.`m_var` vrt_code, a.`m_categ` vgrp_code,
b.tk_date token_date, b.tk_time token_time, c.gr_date gross_date, c.gr_time gr_time, a.m_tare_dt tare_date, a.m_tare_tm tare_time,
a.`m_gross` gross, a.`m_tare` tare, (a.m_gross-a.m_tare-a.m_joona) net, a.`m_joona` joona, a.`m_amount`, a.`m_vehicle_mode` MODE,
a.`m_society_no`, '1' tran_type, a.`for_unit_code`, a.m_tk_type token_type
FROM r_mil_pur a, r_token b, r_gross c
WHERE a.`unit_code` = b.`unit_code`
AND a.`unit_code` = c.`unit_code`
AND a.`season_cntrl` = b.`season_cntrl`
AND a.`season_cntrl` = c.`season_cntrl`
AND a.`m_ind_no` = b.`tk_indno`
AND a.`m_ind_no` = c.`gr_ind_no`;
END
//
并且为了运行此程序,我创建了一个触发器
Delimiter $$
Create Trigger run_proc_purchase_data_mv_centre_insert AFTER INSERT ON 'r_sisl_purpurchase'
FOR EACH ROW
BEGIN
CALL purchase_data_mv_update;
END;
$$
现在当我在 r_sisl_purpurchase 表中插入数据时,它会显示一条错误消息:错误代码:1422存储函数或触发器中不允许显式或隐式提交
如果我放下触发器并手动运行存储过程CALL purchase_data_mv_update
,那么它会在 mv_purchase_data