[英]Creation function in MySQL
I have a database of excursions, tables with information about customers, buses, drivers, bills etc. I m writing a function that calculates a payment for a specified month. But I have some mistakes and don
我有一个游览数据库,包含有关客户、公共汽车、司机、账单等信息的表格。我
m writing a function that calculates a payment for a specified month. But I have some mistakes and don
m writing a function that calculates a payment for a specified month. But I have some mistakes and don
t know how to fix them. m writing a function that calculates a payment for a specified month. But I have some mistakes and don
知道如何解决它们。 Help me please.请帮帮我。 My function:
我的 function:
USE excursions_test;
DELIMITER $$
CREATE FUNCTION sum_bill(excursion_id INT, for_begin DATE, for_end DATE) RETURNS INT
DETERMINISTIC
BEGIN
SELECT excStart = excursion.start_date, excEnd = excursion.end_date, excPrice =( excursion.excursion_duration*excursion.number_of_tourists*bus_model.fuel_for_km*excursion.distance)*1.5,
IF(excStart < for_begin OR excEnd > for_end, 0,
IF(excStart <= for_begin OR excEnd >= for_end AND excEnd <= for_end, DATEDIFF(for_begin, excEnd)*excPrice/30,
IF(excStart >= for_begin AND excEnd >= for_begin AND excEnd <= for_end, DATEDIFF(excStart, excEnd)*excPrice/30,
IF(excStart >= for_begin AND excEnd >= for_end, DATEDIFF(excStart, for_end)*excPrice/30,
IF(excStart <= for_begin AND excEnd >= for_end, DATEDIFF(for_begin, for_end)*excPrice/30, 0)))))
FROM excursion JOIN bus_model ON excursion.bus_model_id = bus_model.bus_model_id
WHERE excursion.excursion_id = excursion_id
RETURN 0; -- there is a mistake
END $$
DELIMITER ;
WHERE excursion.excursion_id = excursion_id
<-- missing ";". WHERE excursion.excursion_id = excursion_id
<-- 缺少“;”。 It should look like this: WHERE excursion.excursion_id = excursion_id;
它应该如下所示:
WHERE excursion.excursion_id = excursion_id;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.