0

以下过程未更新任何行。语法有明显错误吗?我是 MySQL 新手

set autocommit = 0;
DROP procedure IF EXISTS update_fee;
delimiter //
CREATE PROCEDURE update_fee()
BEGIN
  DECLARE done INT DEFAULT FALSE;
  DECLARE t_fee_id int(10);
  DECLARE t_pubco_id int(10);
  DECLARE t_auditor_id int(10);
declare fiscal_period_end_id int(10);
declare t_fiscal_year int(4);
  DECLARE t_audit_id int(10);
  DECLARE cur1 CURSOR FOR SELECT fee_id, pubco_id, auditor_id, fiscal_period_end_id, fiscal_year
                                 from a_fees;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

  OPEN cur1;

  read_loop: LOOP
    FETCH cur1 INTO t_fee_id, t_pubco_id,
                    t_auditor_id , fiscal_period_end_id, t_fiscal_year;
    IF done THEN
      LEAVE read_loop;
    END IF;

    set t_audit_id = get_audit_id (t_pubco_id, 
                                   t_auditor_id, 
                                   concat('''', t_fiscal_year, '-', 
                                          (select concat(fiscal_period_end_month, '-', fiscal_period_end_day, ''''
                                                        )
                                             from a_fiscal_period_end
                                            where t_fiscal_period_end_id = a_fiscal_period_end.fiscal_period_end_id
                                           ), ''''
                                         )
                                   );

update a_fees set audit_id = t_audit_id;

  END LOOP;

  CLOSE cur1;
END;
delimiter ;
4

1 回答 1

0

set autocommit = 0;意味着您必须手动提交更改。使用START TRANSACTIONCOMMITROLLBACK

于 2013-01-10T06:16:57.150 回答