views:

66

answers:

1

I'm messing around with stored procedures for the first time, but can't even create a simple select! I'm using phpMyAdmin and this is my SQL:

DELIMITER // 
CREATE PROCEDURE test_select() 
BEGIN 
SELECT * FROM products LIMIT 10; 
END // 
DELIMITER ;

After submitting that, my localhost does some thinking for a loooong time and eventually loads a page with no content called /phpmyadmin/import.php. After reloading phpMyAdmin and trying to invoke the procedure:

CALL test_select();

I get a "PROCEDURE doesn't exist" error. Any ideas?

+1  A: 

Try to use the delimiter field of phpMyAdmin, as shown in the screenshot below:

Trouble creating stored procedure

Simply put the following in the query window:

CREATE PROCEDURE test_select() 
BEGIN 
    SELECT * FROM products LIMIT 10; 
END

In addition note that there is bug in some older versions of phpMyAdmin, which can cause an error when you call stored procedures that contain SELECT statements from phpMyAdmin.

You may want to check out the following posts for further reading:

This bug effects only phpMyAdmin, and you would still be able to call the stored procedure from anywhere else.

Daniel Vassallo
The problem was actually my use of DELIMITER // directly in the query when I should have been using phpMyAdmin's UI to change the delimiter. Your second link gave me the answer though, so +1. As it happens I've got phpMyAdmin bug too. BAH!
MatW