CREATE PROCEDURE SelectPetDetails
(
IN PetId int
)
BEGIN
SELECT * FROM pet p JOIN animal a on p.int_AnimalId=a.int_AnimalId JOIN breed b on a.int_BreedId=b.int_BreedId JOIN colorpattern c ON a.int_ColorPatternId=c.int_ColorPatternId WHERE int_PetOwnerId= PetId
END
我创建存储过程出了什么问题?
答案 0 :(得分:0)
要创建存储过程,必须将默认定界符;
更改为其他字符,例如'$$'或'//'或所需的任何字符。
-- must change ; to $$ because stored procedure can have ; multiple times
DELIMITER $$
drop procedure if exists SelectPetDetails$$ -- if you plan execute this many times
CREATE PROCEDURE SelectPetDetails (IN PetId int)
BEGIN
SELECT * FROM pet p
JOIN animal a on p.int_AnimalId=a.int_AnimalId
JOIN breed b on a.int_BreedId=b.int_BreedId
JOIN colorpattern c ON a.int_ColorPatternId=c.int_ColorPatternId
WHERE int_PetOwnerId = PetId;
-- mark as end of stored procedure body
END $$
DELIMITER ;
-- return to regular delimiter