Using Stored Procedure on MySQL
Hi,
I've seen several posts regarding using a stored procedure on a database to retrieve data.
I've successfully connected to a MySQL database using ODBC-64bit. I can use Bartender to access a table and its records. I have set up a QueryPrompt to query the database and retrieve the fields.
Now the database contains a stored procedure called get_label_data with one parameter called "ident" which is the primary key. The stored procedure looks up the database table for the ident and returns 7 fields against that ident.
In Bartender, I followed these steps in this link
- Set your Database Connection to use a Custom SQL stored procedure.
- Open the label format.
- Go to File > Database Connection Setup.
- If not already connected, connect to your database.
- Go to the SQL Tab.
- Check Custom SQL.
In Custom SQL I put in
set @q="9949-201";
call get_label_data(@q);
However I get
ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.29]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 get_label_data(@q)' at line 2
When I try the below custom SQL, which is a single constant record
call get_label_data("9949-201");
Bartender is able to read the 7 fields from the database.
I tried using QueryPrompts to see if I can pass a variable to the stored procedure, but I still get the error 42000. I have tried different syntaxes but to no avail.
Could anyone please help with this issue?
Thanks in advance
请先登录再写评论。
评论
0 条评论