how to create stored procedure in mysqlphpadmin 5.0

Posted by Shanky11 under Others on 10/18/2012 | Points: 10 | Views : 894 | Status : [Member] | Replies : 1
when i create sp on phpmyadmin
CREATE PROCEDURE spGetUsers()
BEGIN
SELECT UserName, FirstName, LastName
FROM tblUsers;
END
it gives error
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 3
then i put
delimiter to //
now its shoeing access denied for user 1044....................
what can i do fr it??????????????




Responses

Posted by: Laurenrodriguez on: 10/18/2012 [Member] Starter | Points: 25

Up
0
Down
If you want to get the iterated value of var1 you need the SELECT outside of the WHILE loop. The following works fine in my MySQL install:

DROP PROCEDURE IF EXISTS `str`;
DELIMITER //
CREATE PROCEDURE `str` (IN var1 INT)
BEGIN
WHILE var1 < 5 DO
SET var1 = var1 + 1;
END WHILE;
SELECT var1;
END //
DELIMITER ;

Executing CALL str(1) returns 5


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response