?
Solved

Writing script in MySQL Workbench SQL Editor

Posted on 2010-09-16
1
Medium Priority
?
1,462 Views
Last Modified: 2012-06-27
I Have a routine that works but is ginving me an unexpected result.  I'm trying to debug the sql a routine in the MySQL Editor in MySQL Workbench 5.2.16.  I tried taking the SQL from the routine definition and pasting it into the editor.  I added a line at the beginning for my input parameter.  It will not run because of syntax errors.  The DECLARE statements and the IF statements seem to be unacceptable in the editor.  Here I have embedded an image of the editor window that shows the syntax checking.  snapshot of editor windowThe red squgglies indicate syntax errors.

Is there a reference that states what are acceptable sql statements in the editor?
0
Comment
Question by:pbouchard1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 33697682
pbouchard1,

I don't know of a list, but my understanding is that aside from user-defined variables the only valid syntax is those that can execute as a single-line SQL statement which is why IF ... THEN won't work.  You can use case OR if statements as you would in a SQL query though.

Therefore, to test this you can do this.

Instead of:
DECLARE iSeasonYear INTEGER;
SET iSeasonYear = 2010;

Use:
SET @iSeasonYear = 2010;


You can create the variables that are results from queries on the fly using the INTO methodology you already have in place.


For the IF, you would do this in a SELECT.
SELECT CASE WHEN @WeekNum > 0 THEN @WeekNum WHEN ... THEN ... ELSE 17 END AS `WeekNum`

Hope that helps!

Regards,
Kevin
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question