Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declare syntax error in MYSQL Workbench

How can I declare and set a variable in my MYSQL WORKBENCH in a stored procedure?

It gives a syntax error like unexpected Declare_sym at the first line with a cross sign.

I am using the following code for it:

Declare StartDate datetime

set StartDate = '2013-07-01';
like image 230
Renish Patel Avatar asked Jul 20 '13 06:07

Renish Patel


1 Answers

After some googling, I got my answer.

A Declare statement must be in between Begin and End statement. Additionally, it must be the first statement after the Begin statement.

I got the answer from this wonderful site.

like image 164
Renish Patel Avatar answered Sep 26 '22 19:09

Renish Patel