0
我有以下存储过程设置,它在过去几天刚刚停止工作。有谁知道为什么这可能会停止工作?没有任何数据库表已经改变。MySQL存储过程刚刚停止工作
drop procedure if exists bookings_by_voucher;
delimiter //
create procedure bookings_by_voucher(in start_date date, in end_date date, l_id int)
language sql
deterministic
sql security definer
begin
declare s text;
select distinct group_concat(concat('sum(if(c.gross_value = ',gross_value,',c.net_value,0)) coupon',
cast(gross_value as unsigned))) from coupons into s;
set @query = concat('select ',if(l_id is null, '"All Locations"','l.location_name'),
' location_name,ifnull(b.places, 0) as places, ',
if(start_date is null and end_date is null,'"All Dates"',
if(start_date is null, concat('" <= ',end_date,'"'),
if(end_date is null,concat('" >= ',start_date,'"'),
concat('"',start_date,' - ',end_date,'"')
)
)
),' dates,',
ifnull(s,'"No Coupons"'),
',round(sum(b.price/1.2-ifnull(c.net_value,0)), 2) paidbycard from locations l join bookings b ',
' on l.id = b.location_id ',
concat(if(start_date is null,'',concat(' and b.date >= "', start_date,'"'))),
concat(if(end_date is null,'',concat(' and b.date <= "', end_date,'"'))),
' left join coupons c on b.voucher_code = c.code',
if (l_id is null, ' group by l.id', concat(' where l.id = ', l_id)));
/*select @query;*/
prepare stmt from @query;
execute stmt;
end//
,我从我的应用程序取回(建于Laravel 5.1)的错误是:
SQLSTATE [42000]:语法错误或访问冲突:1064您有一个 错误的SQL语法;请检查与您的 MySQL服务器版本相对应的手册,以获取正确的语法,以便在位置附近使用' paidbycard l在l.id = b.location_id处加入预订b在第1行加入 '(SQL:call bookings_by_voucher(null, null,null))
你得到什么错误? – Matt
您将不得不提供有关“停止工作”的更多信息。 – spender
@Matt我已更新我的问题与错误。 – V4n1ll4