开发者

i bulid stored procedure in MySql server but doesn't work !

how to bulid a stored procedure in MySql server . i wrote the stored procedure outside in note but i don't know how to apply this stored procedure in the server that i am doing the testin . to be clear i download wampSever which includes Mysql ,then i created my tables. but again i don't know the steps that i have to take in orded to use the stored procedure.

my stored procedure:

开发者_运维知识库    CREATE PROCEDURE findHorse
@horseName varchar(15) AS SELECT * FROM horse
WHERE horseName =@horseName

i know that if i wante to execute it i use

exec findHorse

all what i need are : 1. how to create it in mySql. //steps 2.where should i put exec findHorse in order to execute it //steps


In MySQL you execute a stored procedure by 'calling' it:

CALL DoStuff(@Param1);

You create one as follows:

CREATE PROCEDURE DoStuff()
BEGIN
   SELECT Column1
   FROM MyTable;
END;

This might help


I believe this is what you are looking for:

DELIMITER $$
CREATE PROCEDURE `findHorse` (IN `inFindHorse` CHAR(255))
BEGIN
    SELECT * FROM `horse` WHERE `horse`.`horseName` = `inFindHorse`;
END$$
DELIMITER ;

And as Randy noted, the correct way to call this procedure is:

CALL findHorse('Flicka');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜