Answers.Body: <p>After further investigation Yii handles the <code>DELIMITER ;;</code> in the <code>createCommand()</code> method. I just had to remove the opening and closing DELIMITER syntax and execute the <code>Craft::$app-&gt;getDb()-&gt;createCommand("CREATE PROCEDURE ( ... )")-&gt;execute()</code> for it to install.  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-16T22:40:22.957Z
Answers.LastActivityDate: 2018-02-16T22:40:22.957Z
Answers.UserDisplayName: a-am
Body: <p>I am trying to add a MySQL stored procedure to the database on plugin install in Craft 3.  I currently have an install migration calling a function from the safeUp method. In this function I am using <code>Craft::$app-&gt;getDb()-&gt;createCommand(" DELIMITER $$ CREATE PROCEDURE ...")-&gt;execute()</code>. However this does not seem to do the trick.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-16T19:18:06.967Z
Comments.Text: Does the user account Craft is connecting to the database with have [CREATE ROUTINE](https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html#priv_create-routine) permissions?  Craft doesn't require them by default.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-16T19:19:07.230Z
Comments.Text: Also worth mentioning that PostgreSQL has different syntax if you'll be supporting that.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-16T19:46:58.687Z
Comments.Text: The user does have Create Routine Permissions.  The log says there is a syntax error however I have checked the syntax and tested it via SQLPro and it runs. We will start out with MYSQL support until we can convert sql to PostgreSQL.
Comments.UserDisplayName: a-am
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-02-16T20:30:38.103Z
Comments.Text: It says the syntax error is on the first line with the `DELIMITER $$`.
Comments.UserDisplayName: a-am
Tags: <plugin-development><database><craft3><mysql>
Title: Install MySQL stored procedure to database on plugin install in Craft 3
ThreadText: # Install MySQL stored procedure to database on plugin install in Craft 3
  
  (Asked by: username_0 on 2018-02-16)
  
  I am trying to add a MySQL stored procedure to the database on plugin install in Craft 3. I currently have an install migration calling a function from the safeUp method. In this function I am using `Craft::$app->getDb()->createCommand(" DELIMITER $$ CREATE PROCEDURE ...")->execute()`. However this does not seem to do the trick.
  
  **Tags:** plugin-development, database, craft3, mysql
  
  > **Comments:**
  > **username_1**: Does the user account Craft is connecting to the database with have [CREATE ROUTINE](https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html#priv_create-routine) permissions?  Craft doesn't require them by default.  
  > **username_1**: Also worth mentioning that PostgreSQL has different syntax if you'll be supporting that.  
  > **username_0**: The user does have Create Routine Permissions.  The log says there is a syntax error however I have checked the syntax and tested it via SQLPro and it runs. We will start out with MYSQL support until we can convert sql to PostgreSQL.  
  > **username_0**: It says the syntax error is on the first line with the `DELIMITER $$`.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-02-16. Score: 1 | Accepted answer
  
  After further investigation Yii handles the `DELIMITER ;;` in the `createCommand()` method. I just had to remove the opening and closing DELIMITER syntax and execute the `Craft::$app->getDb()->createCommand("CREATE PROCEDURE ( ... )")->execute()` for it to install.
  
  
  ---
  
  