gpt4 book ai didi

mysql - 谁能帮我做一个 MySQL 存储过程

转载 作者:行者123 更新时间:2023-11-29 14:59:12 25 4
gpt4 key购买 nike

我以前从未做过,正在尝试通过在线指南进行工作,但我似乎找不到带参数的好示例。

CREATE PROCEDURE `calcdistance` (
IN ulat varchar,
IN ulon varchar,
IN clat varchar,
IN clon varchar)
BEGIN
Select DEGREES(ACOS(SIN(RADIANS(ulat))
* SIN(RADIANS(clat))
+ COS(RADIANS(ulat))
* COS(RADIANS(clat))
* COS(RADIANS(ulon - ulon))))) * 69.09 AS distance
END

当我尝试这样做时,MySQL 管理员给我的错误是:

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 '  IN ulat varchar, 
    IN ulon varchar,
    IN clat varchar,
    IN cl' at line 2 (error 1064)

最佳答案

你可以试试

DELIMITER $$
DROP PROCEDURE IF EXISTS calcdistance$$
CREATE PROCEDURE `calcdistance` (IN ulat VARCHAR(50), IN ulon VARCHAR(50), IN clat VARCHAR(50), IN clon VARCHAR(50))
BEGIN
SELECT
DEGREES(ACOS(SIN(RADIANS(ulat))
* SIN(RADIANS(clat))
+ COS(RADIANS(ulat))
* COS(RADIANS(clat))
* COS(RADIANS(ulon - ulon))))
* 69.09 AS distance;


END$$

DELIMITER ;

关于mysql - 谁能帮我做一个 MySQL 存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3742205/

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