我想创建一个存储过程,该过程将根据接收到的参数替换视图。
我已经编写了一些代码,但是它总是返回错误:
错误1351:视图的SELECT包含变量或参数
我还尝试创建函数以返回参数,但效果不佳
CREATE PROCEDURE `sp_test`(IN `start_date` DATE, IN `end_date` DATE)
BEGIN
CREATE OR REPLACE VIEW V_test AS (
SELECT
*
FROM hours
WHERE DATE BETWEEN start_date AND end_date
AND
id IN (
SELECT
DISTINCT id
FROM hours2
WHERE date BETWEEN start_date AND end_date
);
END
将感谢您的任何建议