I wrote a stored procedure and want to execute it within a Rake task.
Before calling the stored procedure (through the "call" statement) I should create the procedure with the source command which fails because of the following error:
Mysql2::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 'source import_legacy_database.sql' at line 1: source import_legacy_database.sql
This error happens when the following line is executed:
ActiveRecord::Base.connection.execute "source import_legacy_database.sql"
The same command "source import_legacy_database.sql" runs fine when in the console, but not in the Rake task.
If I don't call that command then
ActiveRecord::Base.connection.execute "call import_legacy_database()"
fails because the database doesn't find the procedure because it does not exist.
Thanks in advanced.