gpt4 book ai didi

Mysql 插入时触发错误

转载 作者:行者123 更新时间:2023-11-30 01:19:27 25 4
gpt4 key购买 nike

我正在尝试创建 SQL 触发器,但遇到某种语法错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7

有什么想法问题出在哪里吗?

create trigger trSaveRows
before delete
on nw_member
for each row
begin
insert into nw_meber_zaloha(id, email, password, stamp, meno,priezvisko, titul, pohlavie, rodnecislo, cisloobcianky, telefon, stav, pocetdeti, mesto, ulica,cislopopisne, cisloorientacne, kraj, castobce, cisloevidencne, cislobytu, dlzkapobytu, mesacnyprijem, povolanie, zamestnanec, zamestnavatel, z_psc, z_castobce, z_ulica, z_telefon, z_mzdaucet, auto, vodicak, blizkaosoba, telefonblizkaosoba, vztah, srazky, schopen, exekucne, inapujcka, dozvedel, psc, ico, z_obec, banka, infobydleni, zivlist, duchodek, privydelek, spz, Tmesto, Tulica, Tpsc, Tcislopopisne, Tcisloorientacne, pracovnipozice, byvalepovolani, zlavauplatnena, pokuta_text, dlzkaprace)
values (old.id, old.email, old.password, old.stamp, old.meno, old.priezvisko, old.titul, old.pohlavie, old.rodnecislo, old.cisloobcianky, old.telefon, old.stav, old.pocetdeti, old.mesto, old.ulica, old.cislopopisne, old.cisloorientacne, old.kraj, old.castobce, old.cisloevidencne, old.cislobytu, old.dlzkapobytu, old.mesacnyprijem, old.povolanie, old.zamestnanec, old.zamestnavatel, old.z_psc, old.z_castobce, old.z_ulica, old.z_telefon, old.z_mzdaucet, old.auto, old.vodicak, old.blizkaosoba, old.telefonblizkaosoba, old.vztah, old.srazky, old.schopen, old.exekucne, old.inapujcka, old.dozvedel, old.psc, old.ico, old.z_obec, old.banka, old.infobydleni, old.zivlist, old.duchodek, old.privydelek, old.spz, old.Tmesto, old.Tulica, old.Tpsc, old.Tcislopopisne, old.Tcisloorientacne, old.pracovnipozice, old.byvalepovolani, old.zlavauplatnena, old.pokuta_text, old.dlzkaprace, now(), user());
end;

最佳答案

语法正确。尝试添加DELIMITER命令,例如-

分隔符$$

CREATE TRIGGER trSaveRows
BEFORE DELETE
ON nw_member
FOR EACH ROW
BEGIN
INSERT INTO nw_meber_zaloha (ID, email, password, stamp, meno, priezvisko, titul, pohlavie, rodnecislo, cisloobcianky, telefon, stav, pocetdeti, mesto, ulica, cislopopisne, cisloorientacne, kraj, castobce, cisloevidencne, cislobytu, dlzkapobytu, mesacnyprijem, povolanie, zamestnanec, zamestnavatel, z_psc, z_castobce, z_ulica, z_telefon, z_mzdaucet, auto, vodicak, blizkaosoba, telefonblizkaosoba, vztah, srazky, schopen, exekucne, inapujcka, dozvedel, psc, ico, z_obec, banka, infobydleni, zivlist, duchodek, privydelek, spz, Tmesto, Tulica, Tpsc, Tcislopopisne, Tcisloorientacne, pracovnipozice, byvalepovolani, zlavauplatnena, pokuta_text, dlzkaprace)
VALUES (OLD.ID, OLD.email, OLD.password, OLD.stamp, OLD.meno, OLD.priezvisko, OLD.titul, OLD.pohlavie, OLD.rodnecislo, OLD.cisloobcianky, OLD.telefon, OLD.stav, OLD.pocetdeti, OLD.mesto, OLD.ulica, OLD.cislopopisne, OLD.cisloorientacne, OLD.kraj, OLD.castobce, OLD.cisloevidencne, OLD.cislobytu, OLD.dlzkapobytu, OLD.mesacnyprijem, OLD.povolanie, OLD.zamestnanec, OLD.zamestnavatel, OLD.z_psc, OLD.z_castobce, OLD.z_ulica, OLD.z_telefon, OLD.z_mzdaucet, OLD.auto, OLD.vodicak, OLD.blizkaosoba, OLD.telefonblizkaosoba, OLD.vztah, OLD.srazky, OLD.schopen, OLD.exekucne, OLD.inapujcka, OLD.dozvedel, OLD.psc, OLD.ico, OLD.z_obec, OLD.banka, OLD.infobydleni, OLD.zivlist, OLD.duchodek, OLD.privydelek, OLD.spz, OLD.Tmesto, OLD.Tulica, OLD.Tpsc, OLD.Tcislopopisne, OLD.Tcisloorientacne, OLD.pracovnipozice, OLD.byvalepovolani, OLD.zlavauplatnena, OLD.pokuta_text, OLD.dlzkaprace, NOW(), USER());
END$$

DELIMITER ;

关于Mysql 插入时触发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18710881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com