DROP PROCEDURE IF EXISTS `simpleproc08`$$
CREATE PROCEDURE `simpleproc08`(IN param0 TEXT, OUT param1 INT)
BEGIN
SET @qry = CONCAT('SELECT COUNT(*) INTO @param1 FROM regions WHERE regions_id IN (', param0, ')');
PREPARE stmt FROM @qry;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET param1 = @param1;
END$$
DELIMITER ;
CALL simpleproc08('1, 2, 3', @a);
SELECT @a;
Result:
@a
------
3
沒有留言:
張貼留言
留個話吧:)