We help IT Professionals succeed at work.

Sql Syntax Call Stored Procedure

Last Modified: 2016-02-10
I have a table called 'capital' in mysql.  I am subtracting 10 from a field called 'pendingCapitalAvailable'.  To accomplish this, I am trying to use a stored procedure that I hope to call from Matlab.  I think this is sql syntax problem and not a matlab problem so read to the end pls.

When I try to execute it in matlab (using runStoredProcedure) it fails because I have an error in my 'sql syntax' .   The matlab command line is:

results = runstoredprocedure(conn, 'test5',{108})
'conn' is my database connection.

The error I get is the following:

java.sql.SQLException: [MySQL][ODBC 3.51 Driver][mysqld-5.0.18-nt-max]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 '{call test5(108)}' at line 1

 I am calling the procedure 'test5'  in the Matlab command line and i am not sure that it is the correct syntax when calling a stored procedure from an external program.  Any ideas?

The stored procedure & mysql version info is below.  Thanks


DROP PROCEDURE IF EXISTS `rt_20071001_ov03`.`test5` $$
CREATE PROCEDURE `test5`(in capitalUsed int)
  UPDATE capital
    SET pendingCapitalAvailable = pendingCapitalAvailable - capitalUsed;
END $$


Server info:
MySQL 5.0.45-community-nt via TCP/IP
MySQL Client Version 5.1.11
InnoDB tables
Watch Question


I am not sure how to fix the problem, but I see the syntax error. Your program is sending the command

{call test5(108)}

to mysql. It should work correctly without the curly braces. Now.... how to remove them? I don't know. Might it be something to do with matlab?
Unlock this solution and get a sample of our free trial.
(No credit card required)


if does not work, Matlab is expecting a cell....
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.