#1442-无法更新存储函数/触发器中的表'table_name',因为调用该存储函数/触发器的语句已使用该表

时间:2019-04-09 03:24:58

标签: mysql triggers

我需要修改一个字段并执行触发器1,并且该触发器将触发触发器2,该触发器应从触发器1的表中删除数据,但出现以下错误,但是单独使用触发器,当2一起抛出时我的错误。

错误

无法更新存储函数/触发器中的表'table_name',因为调用该存储函数/触发器的语句已使用该表。

触发1

#!/usr/bin/perl

use SOAP::Transport::HTTP;
use lib '/tmp/lib';
use Data::Dumper;

SOAP::Transport::HTTP::CGI
  ->dispatch_to('Vendor::Telephony')
  ->handle;
BEGIN {
  package Vendor::Telephony;
  use vars qw(@ISA);
  use MyElements::SMSResponse;
  @ISA = qw(Exporter SOAP::Server::Parameters);
  use SOAP::Lite;
  sub SMS {
    my ($self, $body, $header) = @_;
    my $message = $body->{'SMSMessage'};
    my $number = $body->{'SMSNumber'};

    open(SMS, " | sendmail -r alerts\@example.com $number\@sms.provider.com 2> /dev/null");
    print SMS $message;
    close(SMS);
    return MyElements::SMSResponse->new({Status => 0});
  }
}

触发2

DELIMITER $$
CREATE TRIGGER AU_VEH after update ON vehiculos_vehiculos_aparcados
FOR EACH ROW 
BEGIN
  IF new.estado = 3 THEN BEGIN
    INSERT INTO vehiculos_registro_vehiculos_aparcados VALUES(null, old.patente, old.hora_entrada, old.hora_salida, new.estado, old.total);
  END; END IF;
END$$
DELIMITER ;

0 个答案:

没有答案