Herewith I have given the stored procedure "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 ;
I tried calling the aforeseen procedure using,
CALL GetAvgOut(@a,'Population','city');
SELECT @a;
"select @a" returns null. How can I get the average which is assigned to out parameter "@a"?