3

PHPMyAdmin includes an 'add routine' and 'edit routine' panel in newer versions. The developers talked about how it could be used to write routines that are 'hundreds of lines long', but they only showed single statement routines when they were demonstrating the new features.

https://www.youtube.com/watch?v=7ZRZoCsrKis

The moment I start writing more than one statement it starts giving me syntax errors. Using semicolons doesn't help. Adding "Begin ... End" doesn't help. I just want to know how to write multiple statements in routines, functions, events, and triggers, so that I can automate my database's core functions.

Edit: Jeremy Miller was able to answer my question. (https://stackoverflow.com/a/25905326/4052662)

Community
  • 1
  • 1
  • It's the delimiter that's catching you, most likely. Try switching it to `//`. –  Sep 18 '14 at 03:13
  • There's no 'delimiter' area in the box. These are the options that show up: "Routine name, Type, Parameters (Direction Name Type Length/Values Options), Definition, Is deterministic, Definer, Security type, SQL data access, Comment" – CerebralDreams Sep 18 '14 at 05:07

1 Answers1

3

I had to upgrade my PHPMyAdmin which meant upgrading MySQL, so... now for the answer. When I tried this using a test routine, I kept getting errors, but fortunately the dialog showed the created query. I believe what you're missing is adding in BEGIN and END (if you did what I did).

I took a screen shot of what worked, though, so hoping this gets you going:

Add routine working settings

  • Your solution worked. Updating PHPMyAdmin and MySQL server was a bit of a pain, but it was doable and now my script runs just fine. Thanks for the help! – CerebralDreams Sep 19 '14 at 04:31
  • No problem. When you have an answer to your question, be sure to click the hollow check mark next to the answer. –  Sep 19 '14 at 14:01
  • Make sure you put ; at the end of every line, otherwise you'll get an error saying: `MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line ...` – Pete May 31 '18 at 15:43