Jump to content

Recommended Posts

Posted

OK, so I'm testing out how to use stored procedures in MySQL on my local machine....

 

I create a very simple one that retrieves all the data from a table call `book`.

 

Then run the command "CALL get_all_books()" and all it does is give me this error...

 

 

Error

 

SQL query:

 

SELECT DATABASE( ) AS 'db';

 

MySQL said: Documentation

#2014 - Commands out of sync; you can't run this command now

 

Trying to figure this one out is giving me a headache. Any help would be appreciated.

 

Thanks.

Posted

Did you connect to your database by using mysql_connect()

$dbserver = "localhost";

$dbuser = "root";

$dbpass = "";

$dbname = "test";

 

mysql_connect("$dbserver", "$dbuser", "$dbpass");

 

And also remember to use mysql_select_db() and other commands.

This method is use with PHP.

Posted

Thanks for the reply JcX...

 

I forgot to say that I was using phpmyadmin the whole time, so I don't think that's the problem.

 

I've looked up tutorials online about stored procedures and follow them step by step. But I still get this error.

 

Don't know if it's some weird setting I need to change.

 

I'm using the latest version of wamp with its default settings.

Posted

Where are you running the query from? Did you select a database and then the SQL tab from there, or did you click the SQL icon on the top of the left panel?

Posted
Where are you running the query from? Did you select a database and then the SQL tab from there, or did you click the SQL icon on the top of the left panel?

 

 

I pretty much tried everything :)

 

It seems I can call the stored procedure from a php web page though. So I guess that's just what I'll have to do to test it out.

 

Thanks.

Posted

My guess is that you are running the procedure from a situation where a database has not yet been selected. Make sure you select a database, then enter some random table or something and go to the SQL tab and try there.

Posted

I've tried running the procedure after having selected the database, without selecting it, and from just about every window that I possibly can within phpMyAdmin.

 

Just wondering... have you ever tried running a procedure in phpMyAdmin? If it worked for you, how did you do it?

 

 

I just tried running the procedure from the mysql console and it works. It's definitely something about my installation of phpMyAdmin.

Posted

Hmm, what "MySQL console"? You don't mean the shell console, do you?

 

I've never ran MySQL procedures, although I've worked with MSSQL procedures.

Posted

Yep, that thing running in the "Command Prompt" window. MySQL console, that's what wamp calls it.

 

It's not pretty to look at, but it works :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...