gpt4 book ai didi

Mysql存储过程Select Column into OUT参数

转载 作者:可可西里 更新时间:2023-11-01 08:06:10 25 4
gpt4 key购买 nike

我有一个类似于这个的存储过程,当我试图保存它时,我得到这个错误:

Undeclared variable: my_column

CREATE PROCEDURE p (OUT column_param VARCHAR(25))
BEGIN
SELECT my_column INTO coumn_param limit 1;
END;

为什么我不能选择要返回的列?

这里是我在程序中的实际查询:

select latitude into lat, longitude into lon
from cities cc
inner join countries c on cc.country_id = c.country_id
inner join regions r on cc.region_id = r.region_id and c.country_id = r.country_id
left join locations l on cc.city_id = l.city_id
where
city = coalesce(cty, city) and
country = coalesce(ctry, country) and
region = coalesce(reg, region)
limit 1;

最佳答案

INTO 子句的语法不正确

假设您的查询本身是正确的并且可以正常工作,并且您声明了 latlon 变量更改这部分

select latitude into lat, longitude into lon

SELECT latitude, longitude INTO  lat, lon

这是 SQLFiddle 演示

关于Mysql存储过程Select Column into OUT参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18435146/

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