Er der en grund til, at en lagret procedure ikke kan bruges til at oprette en forberedt erklæring?
DELIMITER //
DROP PROCEDURE IF EXISTS rand_quote//
CREATE PROCEDURE rand_quote()
BEGIN
SET @rand := ROUND((SELECT COUNT(*) FROM quotes) * RAND());
SET @sql := CONCAT('SELECT * FROM quotes LIMIT ', @rand, ', 1');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END;
//
DELIMITER ;