第 5 行有文法錯誤,找不到問題所在 我嘗試更改變數名稱但無濟於事 錯誤查找器也沒有幫助,它只是指向這個「」。 找不到語法錯誤的確切位置。 mysql 8.0
CREATE TRIGGER disaster_reports_auto AFTER UPDATE ON disaster_reports_tbl FOR EACH ROW BEGIN SET @disasterid = (SELECT disaster_reports_id FROM disaster_reports_tbl e WHERE e.disaster_reports_id = NEW.disaster_reports_id); SET @dtreported = (SELECT date_time_reported FROM disaster_reports_tbl e WHERE e.date_time_reported = NEW.date_time_reported); SET @timeincident = (SELECT time_incident FROM disaster_reports_tbl e WHERE e.time_incident = NEW.time_incident); SET @dateincident = (SELECT date_incident FROM disaster_reports_tbl e WHERE e.date_incident = NEW.date_incident); SET @region = (SELECT region FROM disaster_reports_tbl e WHERE e.region = NEW.region); SET @subject = (SELECT subject FROM disaster_reports_tbl e WHERE e.subject = NEW.subject); SET @type = (SELECT incident_type FROM disaster_reports_tbl e WHERE e.incident_type = NEW.incident_type); SET @scale = (SELECT scale_disaster FROM disaster_reports_tbl e WHERE e.scale_disaster = NEW.scale_disaster); SET @overview = (SELECT overview FROM disaster_reports_tbl e WHERE e.overview = NEW.overview); SET @injured = (SELECT injured FROM disaster_reports_tbl e WHERE e.injured = NEW.injured); SET @missing = (SELECT missing FROM disaster_reports_tbl e WHERE e.missing = NEW.missing); SET @death = (SELECT deaths FROM disaster_reports_tbl e WHERE e.deaths = NEW.deaths); SET @province = (SELECT province FROM disaster_reports_tbl e WHERE e.province = NEW.province); SET @municipality = (SELECT municipality FROM disaster_reports_tbl e WHERE e.municipality = NEW.municipality); SET @photo = (SELECT photo FROM disaster_reports_tbl e WHERE e.photo = NEW.photo); SET @valid = (SELECT validity FROM disaster_reports_tbl e WHERE e.validity = NEW.validity); IF NOT EXISTS(SELECT * FROM disaster_reports_verified_tbl n WHERE n.disaster_reports_id = @disasterid) THEN IF (@valid = '1') THEN INSERT INTO disaster_reports_verified_tbl VALUES ('', @disasterid, @dtreported, @timeincident, @dateincident, @region, @subject, @type, @scale, @overview, @injured, @missing, @death, @province, @municipality, @photo); END IF; END IF; END
重寫程式碼,它將成功執行查詢
我已經格式化了程式碼。請檢查以下內容並看看它是否有效: