从MSSQL到MySQL的转换失败

从MSSQL到MySQL的转换失败,mysql,sql,sql-server,Mysql,Sql,Sql Server,我在尝试将MSSQL代码转换为MySQL时遇到了一个问题 我的MSSQL代码是: 我的MySQL代码是: 我得到的错误是: #1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,了解在“begin set p_result='false'附近使用的正确语法;如果(p_id=1)在第5行开始设置p_re’,则结束else 我的代码有什么问题 delimiter // create procedure ProductGroupGenerationSettingsCheck(IN

我在尝试将MSSQL代码转换为MySQL时遇到了一个问题

我的MSSQL代码是: 我的MySQL代码是: 我得到的错误是: #1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,了解在“begin set p_result='false'附近使用的正确语法;如果(p_id=1)在第5行开始设置p_re’,则结束else

我的代码有什么问题

delimiter //
create procedure ProductGroupGenerationSettingsCheck(IN p_id tinyint(1),IN p_result varchar(50)) /*specify what type of parameter it is, IN / OUT / INOUT*/
begin
    select p_id := automaticProductIdGeneration from tbl_Settings ; /*use assignment operator := instead of comparison =*/
    if(p_id = 0) then /*missing a then here*/
    begin 
    set p_result = 'false' ;
    /*don't end the if, when you still have an else if condition*/
    else if (p_id = 1) then /*missing a then again*/
    begin
        set p_result = 'true' ;
    end
    end if; /*missing an if here*/

    select p_result  as 'result' ; /*you could also use an OUT parameter for this...anyway...*/


end //
delimiter ;

第四行的查询中有一个错误。您必须使用下一个查询

select automaticProductIdGeneration into p_id from tbl_Settings;

如果您发布整个错误消息,它可能是有用的。它告诉你第一个问题到底在哪里。

我不知道MySQL,但我认为在MySQL中你不能创建存储过程,至少不像MySQL有存储例程:我在同一个过程中创建了很多次..和Shivan有相同的链接!发布完整的错误消息。其中提到了语法错误的确切位置
delimiter //
create procedure ProductGroupGenerationSettingsCheck(IN p_id tinyint(1),IN p_result varchar(50)) /*specify what type of parameter it is, IN / OUT / INOUT*/
begin
    select p_id := automaticProductIdGeneration from tbl_Settings ; /*use assignment operator := instead of comparison =*/
    if(p_id = 0) then /*missing a then here*/
    begin 
    set p_result = 'false' ;
    /*don't end the if, when you still have an else if condition*/
    else if (p_id = 1) then /*missing a then again*/
    begin
        set p_result = 'true' ;
    end
    end if; /*missing an if here*/

    select p_result  as 'result' ; /*you could also use an OUT parameter for this...anyway...*/


end //
delimiter ;
select automaticProductIdGeneration into p_id from tbl_Settings;