gpt4 book ai didi

带有 IN 日期的 MySQL 过程失败

转载 作者:行者123 更新时间:2023-11-29 07:09:10 27 4
gpt4 key购买 nike

第一次张贴者非常感谢任何帮助。

我完全被 MySQL 存储过程的问题困住了,对它们完全不感兴趣。

这是当前编写的过程,MySQL 可以毫无问题地接受它,因此除非存在语法错误,否则该过程是正确编写的。

但是当我调用程序时调用测试 (2011-04-01, 2011-04-07); 没有返回结果,但 select 语句工作正常。

CREATE PROCEDURE `NewProc`(IN `@StartDate` date,IN `@EndDate` date)

BEGIN

SELECT aux1, aux2, aux3, aux4, date, id, type,
CASE
WHEN results = 'pass' THEN '1'
WHEN results = 'fail' THEN '0'
ELSE '-1'
END AS CertStatus,
CASE
WHEN results = 'pass' THEN '1'
WHEN results = 'fail' THEN '0'
ELSE '-1'
END AS TestStatus,
CASE
WHEN results = 'pass' THEN '1'
WHEN results = 'fail' THEN '0'
ELSE '-1'
END AS TestStatus,
CASE
WHEN results = 'pass' THEN '1'
WHEN results = 'fail' THEN '0'
ELSE '-1'
END AS TestStatus
from completed
WHERE date >= '@StartDate' and date <= '@EndDate';
END;

最佳答案

快速整理 - 我会把它留给“@You”来找出“差异”,并且不止“1”

delimiter ;

drop procedure if exists list_test_status;

delimiter #

create procedure list_test_status
(
in p_start_date date,
in p_end_date date
)
begin

select aux1, aux2, aux3, aux4, date, id, type,
case
when results = 'pass' then 1
when results = 'fail' then 0
else -1
end as CertStatus,
case
when results = 'pass' then 1
when results = 'fail' then 0
else -1
end as TestStatus,
case
when results = 'pass' then 1
when results = 'fail' then 0
else -1
end as TestStatus,
case
when results = 'pass' then 1
when results = 'fail' then 0
else -1
end as TestStatus
from
completed
where
date >= p_start_date and date <= p_end_date;

end#

delimiter ;

call list_test_status(curdate() - interval 1 month, curdate());

关于带有 IN 日期的 MySQL 过程失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5600868/

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