Is declare in mysql giving syntax error?

家住魔仙堡 提交于 2021-02-11 09:38:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!