By tmnt09 on
Hello, I implemented a stored procedure and can successfully create it from mysql and call it from my php application. Now, I am trying to put the create in my module's install file so the upgrade will take care of sp creation but I keep getting 'sql syntax' error when I run the upgrade.php. Please note that the same sql executes without any errors when I run it from mysqladmin/phpMyadmin.
Any help is appreciated.
Comments
Please post the entire SQL
Please post the entire SQL error that drupal is displaying so that we can better assist you in resolving your issue.
This is the error I get: user
This is the error I get:
user warning: 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 'DELIMITER $ CREATE PROCEDURE sp_getOrgs() BEGIN DECLARE loop' at line 1 query: update_sql
in C:\workspace\2.x\includes\database.mysqli.inc on line 156
Thank you.
Eliminate the delimiter
I had the same problem you had. Eliminate the "DELIMITER $", it is not necesarry when you create the SP from PHP.
For example this is how I do it:
Example filename: sp_mystoredprocedure1.sql
Once you run that SQL code from PHP, MySQL automatically adds the "DELIMITER $" when it "stores" the procedure. You can verify this by opening the procedure for editing using a MySQL command or GUI editor like MySQL Query Editor.