我有以下形式的程序:
DELIMITER //
create procedure cl.getcoords(lat FLOAT(15,12), lon FLOAT(15,12), distance int)
BEGIN
declare tlat FLOAT(15,12);
declare tlon FLOAT(15,12);
declare tcoslat FLOAT(20,16);
SELECT lat, lon, cos_lat into tlat, tlon, tcoslat FROM cl.mrkrs WHERE cl.getcoordsdistance(lat, lon, tlat, tlon, tcoslat, distance) IS TRUE LIMIT 100;
END //
DELIMITER ;
当我调用此过程时,没有得到任何结果。怎么了?
最佳答案
我终于做了以下事情来得到我想要的东西:
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `getcoords`(lat FLOAT(15,12), lon FLOAT(15,12), distance int)
BEGIN
-- declare tlat FLOAT(15,12);
-- declare tlon FLOAT(15,12);
-- declare tcoslat FLOAT(20,16);
SET @s = CONCAT('SELECT lat , lon , cos_lat FROM cl.mrkrs WHERE cl.getcoordsdistance(',lat,',' ,lon,', lat, lon, cos_lat,',distance,') IS TRUE LIMIT 100');
prepare stmt1 from @s;
execute stmt1;
deallocate prepare stmt1;
END$$
DELIMITER ;
关于mysql - MYSQL:如何将选择stmt中的列值传递给函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45180843/