Sql Syntax Call Stored Procedure

Posted on 2007-10-10
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
Question by:jmokrauer
    LVL 24

    Expert Comment

    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?
    LVL 24

    Accepted Solution

    What if you tried

    results = runstoredprocedure(conn, 'test5',108)

    Author Comment

    if does not work, Matlab is expecting a cell....

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now