。由此我給存儲過程 「GetAvgOut」:調用存儲過程的輸出參數
delimiter //
DROP PROCEDURE IF EXISTS GetAvgOut//
CREATE DEFINER = 'MailIntimator'@'127.0.0.1' PROCEDURE GetAvgOut(OUT average INT,IN col VARCHAR(30),IN tbl VARCHAR(30))
READS SQL DATA
COMMENT 'returns average'
BEGIN
SET @userVar = CONCAT(' SELECT AVG(' , col , ') FROM ' , tbl);
PREPARE stmt FROM @userVar;
EXECUTE stmt;
END;
//
delimiter ;
我打過電話使用aforeseen程序,
CALL GetAvgOut(@a,'Population','city');
SELECT @a;
「選擇@a」 返回null。我怎樣才能得到分配給參數「@a」的平均值?
爲什麼average聲明爲int,而不是float字段類型? – 2009-07-15 08:18:31
嘗試: CALL GetAvgOut(@ average,'Population','city'); SELECT @average; – 2009-07-15 08:20:25