Hi,
I am trying to find an easy way to deploy updated stored procedures to my clients, without accessing the MySQL Workbench and using the Import module.
I have my stored procedures exported to a .sql file with the export module of MySQL Export module.
I am trying to simulate something like reading the content of .sql file and execute it. This is my code, Unfortunately it gives an syntax error.
SET @stmt=load_file('C:/fingertest/fingerhotel.sql');
PREPARE sqlStmt FROM @stmt;
EXECUTE sqlStmt;
DEALLOCATE PREPARE sqlStmt;
I solved it,
Actually, the sql file generated with the workbench export module, comes with a USE command inside.
Loading the content of the sql file into a string, with the USE command included, was causing problems when it comes to execution with prepare commands. So, I took out the USE command, and it works.
Omer-Pitou
ASKER
Oh sorry, I just noticed that with 2 or more commands in the sql, it gives error.
Find attached a test file, and the error point to the second create table command. It is something like 'syntax error near create ....
jimyX
Please note, as per MySQL manual, you can not execute multiple queries.
The text must represent a single statement, not multiple statements.
BTW, no attachment!!!
PS: If you are interested, I can help you by creating a simple application to execute that file for you, instead of relying on query. So you change nothing, you just connect to MySQL and provide the path of that multiple queries file, and the application executes the queries for you.
Actually, the sql file generated with the workbench export module, comes with a USE command inside.
Loading the content of the sql file into a string, with the USE command included, was causing problems when it comes to execution with prepare commands. So, I took out the USE command, and it works.