Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Writing script in MySQL Workbench SQL Editor

Posted on 2010-09-16
1
Medium Priority
?
1,489 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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

604 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