问题
I'm new to mysql and I'm trying to create a stored procedure but getting syntax error due to declare a variable. The version of mysql I'm using is 5.5.43 and my procedure is:
CREATE PROCEDURE spSearch
(
p_ACTION INT,
p_PROJECT_CUSTOMER INT,
p_PROJECT_NAME VARCHAR(50),
p_PROJECT_SALESPERSON INT,
p_PROJECT_MANAGER INT,
p_PROJECT_PMF INT,
p_PROJECT_TYPE INT,
p_PROJECT_DESIGNER INT,
p_PROJECT_AANDD INT,
p_PROJECT_REFD INT,
p_PROJECT_VENDOR INT,
p_PROJECT_GENERALCONTRACTOR INT,
p_PROJECT_PUNCHLIST varchar(1),
p_PROJECT_LOCATION INT,
p_PROJECT_CLIENTTYPE INT,
p_PROJECT_INSTALLDATE VARCHAR(50),
p_PROJECT_INSTALLDATETO VARCHAR(50),
p_PROJECT_ORDERENTRYDATE VARCHAR(50),
p_PROJECT_ORDERENTRYDATETO VARCHAR(50),
p_PROJECT_MOVEINDATE VARCHAR(50),
p_PROJECT_MOVEINDATETO VARCHAR(50),
p_PROJECT_ACTIVE_FLAG VARCHAR(1)
)
BEGIN
DECLARE ABC VARCHAR(1400);
END;
I'm getting this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 28
Please help to remove this syntax error.
回答1:
It seems that you have a problem with your delimiters. try this:
delimiter //
CREATE PROCEDURE spSearch
(
p_ACTION INT,
p_PROJECT_CUSTOMER INT,
p_PROJECT_NAME VARCHAR(50),
p_PROJECT_SALESPERSON INT,
p_PROJECT_MANAGER INT,
p_PROJECT_PMF INT,
p_PROJECT_TYPE INT,
p_PROJECT_DESIGNER INT,
p_PROJECT_AANDD INT,
p_PROJECT_REFD INT,
p_PROJECT_VENDOR INT,
p_PROJECT_GENERALCONTRACTOR INT,
p_PROJECT_PUNCHLIST varchar(1),
p_PROJECT_LOCATION INT,
p_PROJECT_CLIENTTYPE INT,
p_PROJECT_INSTALLDATE VARCHAR(50),
p_PROJECT_INSTALLDATETO VARCHAR(50),
p_PROJECT_ORDERENTRYDATE VARCHAR(50),
p_PROJECT_ORDERENTRYDATETO VARCHAR(50),
p_PROJECT_MOVEINDATE VARCHAR(50),
p_PROJECT_MOVEINDATETO VARCHAR(50),
p_PROJECT_ACTIVE_FLAG VARCHAR(1)
)
BEGIN
DECLARE ABC VARCHAR(1400);
END//
delimiter ;
来源:https://stackoverflow.com/questions/32732625/is-declare-in-mysql-giving-syntax-error