1、MySQL的存储过程定义为:
BEGIN
SELECT * FROM
(select 派单时间,派单人,流水号,车辆单位,车牌号码,
cast(GPS北斗维修派单 as DECIMAL) as GPS北斗维修派单
from all_in
WHERE 派单时间
BETWEEN strBeginTime AND strEndTime
ORDER BY 派单时间 DESC)t3
union all
SELECT * FROM
(select
cast('合计' as CHAR) as 派单时间,
cast('' as CHAR) as 派单人,
cast('' as CHAR) as 流水号,
cast('' as CHAR) as 车辆单位,
cast('' as CHAR) as 车牌号码,
sum(GPS北斗维修派单)
from all_in
WHERE 派单时间
BETWEEN strBeginTime AND strEndTime
ORDER BY 派单时间 DESC)t4;
END
2、存储过程的参数定义为:in strBeginTime varchar(20),in strEndTime varchar(20)
3、delphi代码中的调用,是通过TMyQuery调用的,代码如下:
with myqry13 do
begin
Close;
SQL.Clear;
SQL.Add('call p_allSend(:strBegin, :strEnd)');
Params.CreateParam(ftDateTime,'strBegin',ptInput);
Params.CreateParam(ftDateTime,'strEnd',ptInput);
Params[0].Value := StrToDateTime(StrBeginTime);
Params[1].Value := StrToDateTime(strEndTime);
ShowMessage('3');
Open;
ShowMessage('4');
Active;
end;
其中时间是从datepicker上获得并经过变换得来的datetime值。
strBeginTime := DateTimeToStr(trunc(dtp1.DateTime)) + ' 0:00:00';
strEndTime := DateTimeToStr(trunc(dtp2.DateTime)) + ' 23:59:59';
4、错误显示为showmessage(3)以后,就报错,截图如下:
谁能告诉我为什么StrToDateTime没有起到把string转换为datetime的作用?