views:

1029

answers:

2

Hello, I am learnig how to use mysql procedures (google book) and one example goes as:

DELIMITER $$

DROP PROCEDURE IF EXISTS my_sqrt$$
CREATE PROCEDURE my_sqrt(input_number INT, OUT out_number FLOAT)
BEGIN
    SET out_number=SQRT(input_number);
END$$

DELIMITER ;

Which compiles fine... (I am using mySQL Query Browser in ubuntu). But, when I call the procedure:

CALL my_sqrt(4,@out_value);

(also in query browser)

It returns an error (1064) check the manual that correspond to the...

I don't understand why (if the calling procedure described in book is correct It should work for me to...)

+1  A: 

Unable to replicate. It worked fine for me:

mysql> CALL my_sqrt(4, @out_value);
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @out_value;
+------------+
| @out_value |
+------------+
| 2          | 
+------------+
1 row in set (0.00 sec)

Perhaps you should paste the entire error message instead of summarizing it.

chaos
Here is the entire error: 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 'SELECT @out_value' at line 2
domagoj412
Okay. It sounds to me like it's something to do with your being in Query Browser. Try it from the mysql command line tool.
chaos
A: 

I just tried to call a function in terminal rather then MySQL Query Browser and it works. So, it looks like I'm doing something wrong in that program...

I don't know what since I called some procedures before successfully (but there where no out parameters)...

For this one I had entered

CALL my_sqrt(4,@out_value);
SELECT @out_value;

And it results with an error:

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 'SELECT @out_value' at line 2

Strangely, if I write just:

CALL my_sqrt(4,@out_value);

The result message is: "Query canceled"

I guess, for now I will use only terminal...

domagoj412