我创建了一个用于从 FreeRADIUS 访问会计数据的存储过程,该过程已在 MySQL Workbench 中进行了测试并且运行良好,但是当作为 cfquery/cfstoredproc 运行时,我收到错误“执行的参数不正确”。
我已经检查了驱动程序是否设置为 MySQL 4/5(数据库是 MySQL 5),并尝试从 MySQL Workbench 复制和粘贴调用并在不使用 cfqueryparam 的情况下运行,如下所示,但它仍然返回相同的错误。
存储过程是用
DELIMITER $$
CREATE PROCEDURE radius.GetUserDataUsageForMonth(IN StartDate DATE, IN EndDate DATE, IN UserName
VARCHAR(100))
BEGIN
SET @records = (SELECT COUNT(UserName) FROM `radius`.`radacct` WHERE userName = @UserName AND AcctStartTime BETWEEN @StartDate AND @EndDate) - 1;
SET @SqlQuery = 'SELECT SUM(AcctOutputOctets) AS BytesIN, SUM(AcctInputOctets) AS BytesOUT FROM
(SELECT * FROM `radius`.`radacct` WHERE userName = @UserName AND AcctStartTime BETWEEN @StartDate AND @EndDate LIMIT ?
UNION ALL
SELECT * FROM `radius`.`radacct` WHERE userName = @UserName AND AcctStartTime < @StartDate ORDER BY AcctStartTime DESC LIMIT 1) AS Totals;';
PREPARE stmt FROM @SqlQuery;
EXECUTE stmt USING @records;
DEALLOCATE PREPARE stmt;
END $$
DELIMITER ;
要调用它,我正在使用:
<cfquery name="qRadAccount_currentData" datasource="#application.datasource_radius#">
CALL radius.GetUserDataUsageForMonth('2011-06-01','2011-07-01','ryan.french');
</cfquery>
我也试过
<cfstoredproc procedure="radius.GetUserDataUsageForMonth" datasource="#application.datasource_radius#" result="qRadAccount_currentData">
<cfprocparam cfsqltype="cf_sql_date" value="2011-06-01">
<cfprocparam cfsqltype="cf_sql_date" value="2011-07-01">
<cfprocparam cfsqltype="cf_sql_varchar" value="ryan.french">
</cfstoredproc>