gpt4 book ai didi

mysql - 存储过程: Data truncation: Truncated incorrect DOUBLE value

转载 作者:行者123 更新时间:2023-11-29 21:59:09 26 4
gpt4 key购买 nike

我缺乏构建存储过程的经验,并且遇到了这个错误,我无法理解背后的原因:

[2015-09-29 01:01:55] [22001][1292] Data truncation: Truncated incorrect DOUBLE value: '5609d3e6c89be'

值“5609d3e6c89be”是“FlightID”。

我的存储过程代码:

DROP PROCEDURE IF EXISTS initFlight;
CREATE PROCEDURE initFlight (flightid VARCHAR(50))
BEGIN

-- rules, player should only fly if not in jail, not in missions
-- and is in the city the flight will take off from
DECLARE fname VARCHAR(50); -- flight name
DECLARE depart int; -- city number of departure
DECLARE dest int; -- city number of destination

-- assign values to our variables
select flightname, source_airport, destination_airport
into fname, depart, dest
from airport_flights where id = flightID;

-- show in console the variable values for debugging
-- select concat(" fname: ", fname, " depart: ", depart, " dest: ", dest);

-- set players flying means p.live = '-1'
update `[players]` as p set p.live = '-1' where p.id in (
select id from airport_tickets where flight = flightID
) and p.live = depart;

-- insert into alerts a message for players boarding the flight (are in the city of departure)
insert into player_alerts (alert_text, player_id)
select concat("Boarding flight ", fname) as alert_text, p.id as player_id from `[players]` as p
where p.id in (
select id from airport_tickets where flight = flightID
) and p.live = depart;

-- insert into alerts a message for players that missed the flight (are not in the city of departure)
insert into player_alerts (alert_text, player_id)
select concat("You missed flight ", fname) as alert_text, id as player_id from `[players]` as p
where p.id in (
select id from airport_tickets where flight = flightID
) and p.live != depart;

-- stop sales
update airport_flights set selling_tickets = 0 where id = flightID;

END;
call initFlight('5609d3da016bf');

这里发生了什么?为什么我的“字符串”被转换为 double 然后被截断?

airport_flights.id is varchar(50)
airport_flights.source_airport is int(11)
airport_flights.destination_airport is int(11)

airport_tickets.id is varchar(50)
airport_tickets.flight is varchar(50)
airport_tickets.owner_id is int(11)


`[players]`.id is int(11)
`[players]`.live is int(11)
`[players]`.name is varchar(200)

player_alerts.id is int(11)
player_alerts.alert_text is varchar(250)

PS:如果您需要更多信息,请告诉我,一如既往地欢迎批评

最佳答案

经过多次头脑碰撞,我发现问题出在子查询中,当我想将 airport_tickets.owner_id 与玩家匹配时,我将 airport_tickets.id (varchar) 与player.id (int) 混合在一起。 ID。

我只是在删除所有内容并重新编写所有内容作为消除任何代码盲目性的措施时才发现这一点(当你的大脑读取它认为代码的作用而不是实际编写的内容时)。

关于mysql - 存储过程: Data truncation: Truncated incorrect DOUBLE value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32833746/

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