I'm on Windows 7 ultimate 32bit + xampp 1.7.2 [MySQL v5.1.37]
This is my stored procedure :
delimiter //
CREATE PROCEDURE updatePoints(IN parentid INT(5),IN userid INT(5))
DECLARE chpoints INT(5);
BEGIN
SELECT points INTO chpoints FROM quiz_challenges WHERE id = parentid;
UPDATE quiz_users SET points = points + chpoints WHERE forumid=userid;
END;
//
delimiter ;
At first it was showing error 1064 while creating stored procedure. I added delimiters part and when I tried running the query from phpmyadmin, Firefox went into not responding state. After that I started Internet Explorer and tried opening my pages which use the same database, it worked fine. However, I tried opening phpmyadmin and IE went into not responding state as well. I restarted both servers. Later restarted PC. Tried again but its same behavior.
So whats wrong with this tiny little code ? Am I missing something which might be causing infinite loop ?
Thanks
In my experience phpmyadmin does not like the use of
delimiter //
inside the SQL query window. Instead, there is a "delimiter" text box in the phpmyadmin SQL query window, the contents of which are set to ";" by default. Enter "//" in this text box instead of ";", and try your query with thedelimiter //
anddelimiter ;
lines omitted.OBSERVATION #1
The order is incorrect. The
DECLARE chpoint INT(5)
should be afterBEGIN
, not beforeOBSERVATION #2
You should make sure of the following for
quiz_users
forum_id
is indexedpoints
is not indexed (That's right, I said not indexed because the value would be incremented and cause the BTREE for that column's index to shuffle that key's place in the index).OBSERVATION #3
If the PHP script is iterating
parentid
anduserid
values, BIG OUCH !!!This would indicate that a browser session is doing round trips to feed each call to ther stored procedure. You should think about passing all the
parentid
anduserid
combinations in a table and letting the stored procedure handle it on the server side with doing round trips from the browser session.