2013-06-20 135 views
0

我的触发器完全安装成功,但更新后表显示错误。请让我知道需要更改此代码。更新表后触发器不工作

 
#1328 - Incorrect number of FETCH variables 
DELIMITER // 
CREATE TRIGGER `getcrm`.`update_round_date` AFTER UPDATE ON `getcrm`.`vtiger_stockcheckcf` 
FOR EACH ROW BEGIN 
DECLARE done INT DEFAULT 0; 

DECLARE curTipo CURSOR FOR SELECT * FROM vtiger_crmentity LEFT JOIN 
vtiger_stockcheck ON 
vtiger_crmentity.crmid = vtiger_stockcheck.stockcheckid LEFT JOIN 
vtiger_stockcheckcf ON 
vtiger_crmentity.crmid = vtiger_stockcheck.stockcheckid WHERE 
vtiger_stockcheckcf.cf_746 = 'Pending'; 

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; 

    OPEN curTipo; 
     ins_loop: LOOP 
      FETCH curTipo INTO crmid,smcreatorid,smownerid,modifiedby,createdtime,modifiedtime,curEdate, 
stockcheck,stockcheckid,cf_709,cf_710,cf_711,cf_712,cf_713,cf_714,cf_715,cf_716,cf_717,cf_718,cf_719,cf_720,cf_721,cf_722,cf_723,cf_724, 
cf_725,cf_726,cf_727,cf_728,cf_729,cf_730,cf_731,cf_732,cf_733,cf_734,cf_735,cf_736,cf_737,cf_738,cf_739,cf_740,cf_741,cf_742,cf_743,cf_744, 
cf_745,cf_746,cf_747,cf_748,cf_844,cf_1079,cf_1080,cf_1081; 
      IF done THEN 
       LEAVE ins_loop; 
      END IF; 
      INSERT INTO vtiger_cancellationcf values ('vtiger_crmentity.crmid','vtiger_stockcheckcf.cf_709','vtiger_stockcheckcf.cf_710', 
'vtiger_stockcheckcf.cf_711','vtiger_stockcheckcf.cf_712',`vtiger_stockcheckcf.cf_713`,`vtiger_stockcheckcf.cf_714`,`vtiger_stockcheckcf.cf_715`, 
`vtiger_stockcheckcf.cf_716`,`vtiger_stockcheckcf.cf_717`,`vtiger_stockcheckcf.cf_718`,`vtiger_stockcheckcf.cf_719`,`vtiger_stockcheckcf.cf_720`, 
`vtiger_stockcheckcf.cf_721`,`vtiger_stockcheckcf.cf_722`,`vtiger_stockcheckcf.cf_723`,`vtiger_stockcheckcf.cf_724`,`vtiger_stockcheckcf.cf_725`, 
`vtiger_stockcheckcf.cf_726`,`vtiger_stockcheckcf.cf_727`,`vtiger_stockcheckcf.cf_728`,`vtiger_stockcheckcf.cf_729`,`vtiger_stockcheckcf.cf_730`, 
`vtiger_stockcheckcf.cf_731`,`vtiger_stockcheckcf.cf_732`,`vtiger_stockcheckcf.cf_733`,`vtiger_stockcheckcf.cf_734`,`vtiger_stockcheckcf.cf_735`, 
`vtiger_stockcheckcf.cf_736`,`vtiger_stockcheckcf.cf_737`,`vtiger_stockcheckcf.cf_738`,`vtiger_stockcheckcf.cf_739`,`vtiger_stockcheckcf.cf_740`, 
`vtiger_stockcheckcf.cf_741`,`vtiger_stockcheckcf.cf_742`,`vtiger_stockcheckcf.cf_743`,`vtiger_stockcheckcf.cf_744`,`vtiger_stockcheckcf.cf_745`, 
`vtiger_stockcheckcf.cf_746`,`vtiger_stockcheckcf.cf_747`,`vtiger_stockcheckcf.cf_748`,`vtiger_stockcheckcf.cf_844`,`vtiger_stockcheckcf.cf_1079`, 
`vtiger_stockcheckcf.cf_1080`,`vtiger_stockcheckcf.cf_1081`); 

INSERT INTO vtiger_cancellation (cancellationid,cancellation,scheckid) 
values ('vtiger_crmentity.crmid',' ','vtiger_stockcheckcf.cf_709'); 
INSERT INTO vtiger_crmentity values 
('vtiger_crmentity.crmid','vtiger_crmentity.smcreatorid','vtiger_crmentity.smownerid', 
'vtiger_crmentity.smcreatorid','Cancellation','','curEdate','curEdate','','','0','1','0',''); 
DELETE FROM vtiger_crmentity_seq where id='vtiger_crmentity.crmid'; 
INSERT INTO vtiger_crmentity_seq values ('vtiger_crmentity.crmid'); 
     END LOOP; 
    CLOSE curTipo; 
END 
// 
DELIMITER  
+1

代码在哪里? –

+0

只是在黑暗中疯狂的猜测,但它听起来像你有一个游标,选择x列,并试图在y变量中获取它们... – Stephan

+0

我已经声明所有变量 –

回答

0

我认为你应该直接使用的变量。您的触发器已被正确编译,但您没有使用变量值。你正在插入变种的名字。

INSERT INTO vtiger_cancellationcf 
values (crmid,smcreatorid,smownerid,modifiedby,createdtime, modifiedtime, curEdate, 
    stockcheck ,stockcheckid, cf_709,cf_710, cf_711,cf_712, cf_713,cf_714, cf_715,cf_716, cf_717,cf_718, cf_719, cf_720, cf_721 ,cf_722,cf_723,cf_724, cf_725, cf_726, cf_727, cf_728, cf_729, cf_730, cf_731, cf_732, cf_733, cf_734, cf_735, cf_736, cf_737, cf_738, cf_739, cf_740, cf_741,cf_742,cf_743,cf_744, 
    cf_745, cf_746, cf_747,cf_748,cf_844,cf_1079,cf_1080,cf_1081);