我对这个过程的目标是使用星期几来确定服务的调整价格。例如,在周末,价格上涨 10%。周一和周五,价格是一样的。周二至周四减少 5%。最后的信息应该是新的调整价格。
我以为我这样做是正确的。但是我在声明值方面遇到了重大错误。
任何帮助将不胜感激。谢谢你。
Create procedure DayOfWeek( inout p_price decimal(7,2), inout p_date date, out v_msg varchar(10))
begin
declare increase10 double;
set increase10 = p_price * (1.1);
declare decrease5 double;
set decrease5 = p_price * (0.95);
declare increase10cast varchar(10);
set increase10cast := cast(increase10 as char);
declare decrease5cast varchar(10);
set decrease5cast := cast(decrease10 as char);
declare regular varchar(10);
set regular := cast(p_price as char );
case
when p_price is null then
set v_msg := 'null';
when p_date is null then
set v_msg := 'null';
when weekday(p_date) in (0, 6) then
set v_msg := increase10cast;
when weekday(p_date) in (1, 5) then
set v_msg := regular;
when weekday(p_date) in (2, 2, 4) then
set v_msg := decrease5cast;
end case;
end;
#