2015-09-29 108 views
0

我缺乏经验,构建存储过程也碰到了这个错误,我不明白背后的原因:存储过程:数据截断:截断不正确DOUBLE值

[2015年9月29日1时01分55秒] [22001] [1292]数据截断:截断不正确DOUBLE值: '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'); 

这到底是怎么回事?为什么我的“字符串”被转换为双精度,然后被截断?

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:如果你需要更多的信息,让我知道和批评是一如既往欢迎

+1

如果你把球员表也放在一起,这将有所帮助。 – e4c5

+0

从http://stackoverflow.com/questions/26743197/err-1292-truncated-incorrect-double-value:**这是真正蹩脚的错误之一,可能与实际问题没有任何关系。**是否知道该过程中的哪个查询出错? – Barmar

+0

现在添加播放器字段。至于错误的查询,我不知道,这些查询是由1,然后结合到存储过程,有没有办法来调试呢? –

回答

0

多跳车左右,我发现这个问题是在子查询我在那里混合后airport_tickets.id(varchar)与player.id(int),当我想将player_tickets.owner_id与player.id匹配时。

我只在删除所有内容并将其重写为删除任何代码失明(当您的大脑读取它认为代码执行的内容而不是实际写入的内容时)的措施时才发现这一点。

相关问题