我在创建一个在 MySQL 中使用 VIEW 的过程时遇到问题,我到处查看,它看起来不错,但它不起作用
这是我的视图,运行良好:
CREATE OR REPLACE VIEW V_Ficha AS SELECT R.Id_rota, R.Tempo, R.Nome, F.Data, F.Tab_pesquisador_Id_pesquisador as Pes,
F.Tab_municipio_Id_municipio as Mun, F.Tab_instrumento_Id_instrumento as Ins FROM Tab_ficha F LEFT JOIN Tab_rota AS R ON F.Tab_rota_Id_rota = R.Id_rota;
这是我的程序:
CREATE OR REPLACE PROCEDURE P_Ficha(IN id INT)
BEGIN
IF id > 1 THEN
SELECT * FROM V_Ficha WHERE Id_rota = id;
ELSE
SELECT 'Id must be greater than 0' AS Msg;
END IF;
END;
我放了分隔符,但它仍然无法正常工作
DELIMITER //
CREATE OR REPLACE PROCEDURE P_Ficha(IN id INT)
BEGIN
IF (id > 1) THEN
SELECT * FROM V_Ficha WHERE Id_rota = id;
ELSE
SELECT 'Id must be greater than 0' AS Msg;
END IF;
END
//
DELIMITER ;