Mysql

ERROR 1064 (42000) 導入期間您的 SQL 語法有錯誤

  • January 14, 2021

MySql 新手。

我有一個來自伺服器版本 5.6.34 的導出文件。我在具有相同版本的伺服器上導入它。我收到如下錯誤:

ERROR 1064 (42000) at line 4343: 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 1
Operation failed with exitcode 1

這是行 (4343)

/*!50003 CREATE*/ /*!50017 DEFINER=`roomroot`@`%`*/ /*!50003 TRIGGER invoicelines_AFTER_UPDATE AFTER UPDATE ON invoicelines

完整程式碼:

DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`roomroot`@`%`*/ /*!50003 TRIGGER invoicelines_AFTER_UPDATE AFTER UPDATE ON invoicelines
FOR EACH ROW
updateTrigger: BEGIN
 IF (@MIGRATION_SKIP_TRIGGERS = TRUE)
 THEN
   LEAVE updateTrigger;
 END IF;

 IF (new.Invoicenumber < 1000000000) THEN /* No history for Proforma invoices */
   IF not (old.AutoGen <=> new.AutoGen) or not (old.Reservation <=> new.Reservation) or not (old.RoomReservation <=> new.RoomReservation) or not (old.SplitNumber <=> new.SplitNumber) 
     or not (old.ItemNumber <=> new.ItemNumber) or not (old.PurchaseDate <=> new.PurchaseDate) or not (old.invoiceNumber <=> new.InvoiceNumber)
     or not (old.ItemID <=> new.ItemID) or not (old.Number <=> new.Number) or not (old.Description <=> new.Description) or not (old.Price <=> new.Price)
     or not (old.VATType <=> new.VATType) or not (old.ilVATPercentage <=> new.ilVATPercentage) or not (old.Total <=> new.Total) or not (old.TotalWOVat <=> new.TotalWOVat) or not (old.Vat <=> new.Vat)
     or not (old.AutoGenerated <=> new.AutoGenerated) or not (old.CurrencyRate <=> new.CurrencyRate) or not (old.Currency <=> new.Currency) or not (old.ReportDate <=> new.ReportDate)
     or not (old.ReportTime <=> new.ReportTime) or not (old.Persons <=> new.Persons) or not (old.Nights <=> new.Nights) or not (old.BreakfastPrice <=> new.BreakfastPrice)
     or not (old.Ayear <=> new.Ayear) or not (old.Amon <=> new.Amon) or not (old.Aday <=> new.Aday) or not (old.ilTmp <=> new.ilTmp)
     or not (old.ilAccountKey <=> new.ilAccountKey) or not (old.ItemCurrency <=> new.ItemCurrency) or not (old.ItemCurrencyRate <=> new.ItemCurrencyRate) or not (old.Discount <=> new.Discount)
     or not (old.Discount_isprecent <=> new.Discount_isprecent) or not (old.ImportRefrence <=> new.ImportRefrence) or not (old.ImportSource <=> new.ImportSource) or not (old.isPackage <=> new.isPackage)
     or not (old.confirmDate <=> new.confirmDate) or not (old.confirmAmount <=> new.confirmAmount) or not (old.RoomReservationAlias <=> new.RoomReservationAlias) or not (old.ItemSource <=> new.ItemSource)
     or not (old.InvoiceIndex <=> new.InvoiceIndex) or not (old.staffCreated <=> new.staffCreated) or not (old.staffLastEdit <=> new.staffLastEdit) or not (old.itemAdded <=> new.itemAdded)
     or not (old.VisibleOnInvoice <=> new.VisibleOnInvoice) or not (old.Revenue <=> new.Revenue) 
     or not (old.parentlineGUID <=> new.parentlineGUID) 
     or not (old.PURCHASE_CURRENCY <=> new.PURCHASE_CURRENCY) or not (old.PURCHASE_UNIT_PRICE <=> new.PURCHASE_UNIT_PRICE) or not (old.PURCHASE_TOTAL_PRICE_WO_TAX <=> new.PURCHASE_TOTAL_PRICE_WO_TAX) 
     or not (old.PURCHASE_TOTAL_PRICE <=> new.PURCHASE_TOTAL_PRICE) or not (old.PURCHASE_TO_NATIVE_CURR_CONV <=> new.PURCHASE_TO_NATIVE_CURR_CONV) 
     or not (old.NATIVE_UNIT_PRICE <=> new.NATIVE_UNIT_PRICE) or not (old.NATIVE_TOTAL_PRICE_WO_TAX <=> new.NATIVE_TOTAL_PRICE_WO_TAX) or not (old.NATIVE_TOTAL_PRICE <=> new.NATIVE_TOTAL_PRICE) 
     or not (old.NATIVE_TO_CHARGE_CURR_CONV <=> new.NATIVE_TO_CHARGE_CURR_CONV)  or not (old.CHARGE_CURRENCY <=> new.CHARGE_CURRENCY) or not (old.CHARGE_UNIT_PRICE <=> new.CHARGE_UNIT_PRICE)
     or not (old.CHARGE_TOTAL_PRICE_WO_TAX <=> new.CHARGE_TOTAL_PRICE_WO_TAX) or not (old.CHARGE_TOTAL_PRICE <=> new.CHARGE_TOTAL_PRICE)
     then
     INSERT INTO invoicelines_history
     (AutoGen, Reservation, RoomReservation, SplitNumber, ItemNumber, PurchaseDate, InvoiceNumber, ItemID, Number, Description, Price, VATType, ilVATPercentage, Total, TotalWOVat, Vat, AutoGenerated,
     CurrencyRate, Currency, ReportDate, ReportTime, Persons, Nights, BreakfastPrice, Ayear, Amon, Aday, ilTmp, ilAccountKey, ItemCurrency, ItemCurrencyRate, Discount, Discount_isprecent,
     ImportRefrence, ImportSource, isPackage, confirmDate, confirmAmount, RoomReservationAlias, ItemSource, InvoiceIndex, staffCreated, staffLastEdit, itemAdded, VisibleOnInvoice, Revenue,
     PURCHASE_CURRENCY, PURCHASE_UNIT_PRICE, PURCHASE_TOTAL_PRICE_WO_TAX, PURCHASE_TOTAL_PRICE, PURCHASE_TO_NATIVE_CURR_CONV, 
     NATIVE_UNIT_PRICE, NATIVE_TOTAL_PRICE_WO_TAX, NATIVE_TOTAL_PRICE, NATIVE_TO_CHARGE_CURR_CONV,
     CHARGE_CURRENCY, CHARGE_UNIT_PRICE, CHARGE_TOTAL_PRICE_WO_TAX, CHARGE_TOTAL_PRICE,
     action, lineGUID, lineId, parentlineGUID)
       SELECT
         AutoGen, Reservation, RoomReservation, SplitNumber, ItemNumber, PurchaseDate, InvoiceNumber, ItemID, Number, Description, Price, VATType, ilVATPercentage, Total, TotalWOVat, Vat, AutoGenerated,
         CurrencyRate, Currency, ReportDate, ReportTime, Persons, Nights, BreakfastPrice, Ayear, Amon, Aday, ilTmp, ilAccountKey, ItemCurrency, ItemCurrencyRate, Discount, Discount_isprecent,
         ImportRefrence, ImportSource, isPackage, confirmDate, confirmAmount, RoomReservationAlias, ItemSource, InvoiceIndex, staffCreated, staffLastEdit, itemAdded, VisibleOnInvoice, Revenue,
         PURCHASE_CURRENCY, PURCHASE_UNIT_PRICE, PURCHASE_TOTAL_PRICE_WO_TAX, PURCHASE_TOTAL_PRICE, PURCHASE_TO_NATIVE_CURR_CONV,
         NATIVE_UNIT_PRICE, NATIVE_TOTAL_PRICE_WO_TAX, NATIVE_TOTAL_PRICE, NATIVE_TO_CHARGE_CURR_CONV,
         CHARGE_CURRENCY, CHARGE_UNIT_PRICE, CHARGE_TOTAL_PRICE_WO_TAX, CHARGE_TOTAL_PRICE,
         'UPDATE_RECORD', lineGUID, NEW.ID, parentlineGUID
       FROM invoicelines WHERE ID = NEW.ID;
   END IF;
 END IF;
END; */;;

此行的相同版本出現在此錯誤行之前,並且不會給出錯誤。工作線不報錯

   /*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`roomroot`@`%`*/ /*!50003 TRIGGER invoicelines_BEFORE_UPDATE BEFORE UPDATE ON invoicelines 
FOR EACH ROW
BEGIN
 DECLARE rate DOUBLE DEFAULT 1.0;
    
 IF IFNULL((SELECT value FROM pms_settings WHERE keyGroup='INVOICE_HANDLING_FUNCTIONS' AND `key`='SHOW_INCLUDED_BREAKFAST_ON_INVOICE'), 'FALSE') != 'TRUE' THEN
   SET NEW.revenueCorrection=0.0;
   SET NEW.revenueCorrectionVAT=0.0;
 END IF;
     
 if (NEW.VATType is not null) then
   set NEW.ilVATPercentage = (select max(v.VATPercentage) from vatcodes v where v.VATCode=NEW.VATType);
 end if;
   
   /* Fix for externally added invoicelines which dont set revenue field by themselves */
 if NEW.itemsource = 'EXTERNAL' and NEW.revenue = 0 then
     set NEW.revenue = NEW.total;
 end if;
   
 SET rate = IF(IFNULL(NEW.currencyrate, 0) != 0, NEW.currencyrate, 1.0);

 /* Sync new fields when old fields have changed */
 IF (NEW.revenue <> OLD.revenue) 
     OR (NEW.currency <> OLD.currency) 
     OR (NEW.currencyRate <> OLD.currencyRate) 
     THEN
   SET NEW.NATIVE_TOTAL_PRICE = NEW.revenue;
   SET NEW.NATIVE_UNIT_PRICE = NEW.revenue / NEW.number;
   SET NEW.NATIVE_TOTAL_PRICE_WO_TAX = NEW.totalWOVat;
   SET NEW.PURCHASE_TOTAL_PRICE = NEW.revenue / rate;
   SET NEW.PURCHASE_UNIT_PRICE = NEW.revenue / NEW.number / rate;
   SET NEW.PURCHASE_TOTAL_PRICE_WO_TAX = NEW.totalWOVat / rate;
   SET NEW.PURCHASE_CURRENCY = NEW.Currency;
   SET NEW.PURCHASE_TO_NATIVE_CURR_CONV = NEW.currencyRate;
   SET NEW.CHARGE_CURRENCY = NEW.currency;
 END IF;

   /* Fill PURCHASE field on open invoices */
 IF (NEW.PURCHASE_TOTAL_PRICE IS NULL) THEN
     SET NEW.PURCHASE_TOTAL_PRICE = NEW.revenue / rate;
     SET NEW.PURCHASE_UNIT_PRICE = NEW.revenue / NEW.number  / rate;
     SET NEW.PURCHASE_TOTAL_PRICE_WO_TAX = NEW.totalWOVat / rate;
     SET NEW.PURCHASE_CURRENCY = NEW.Currency;
     SET NEW.PURCHASE_TO_NATIVE_CURR_CONV = rate;
     SET NEW.CHARGE_CURRENCY = NEW.currency;
 END IF;

 IF (IFNULL(NEW.invoicenumber, -1) > 0 AND NEW.CHARGE_TOTAL_PRICE IS NULL) THEN
     SET NEW.CHARGE_TOTAL_PRICE = NEW.revenue / rate;
     SET NEW.CHARGE_UNIT_PRICE = NEW.revenue / NEW.number / rate;
     SET NEW.CHARGE_TOTAL_PRICE_WO_TAX = NEW.totalWOVat / rate;
     SET NEW.CHARGE_CURRENCY = NEW.currency;
     SET NEW.NATIVE_TO_CHARGE_CURR_CONV = 1 / rate;
 END IF;
   
END */;; 

為什麼會導致錯誤?我在同一個伺服器版本上。並且正確執行同一類型的行

觸發器的最後一行導致了我的問題。它應該工作。請參閱 Akina 的評論範例

END; */;;

應該

END */;;

引用自:https://dba.stackexchange.com/questions/273626