Search code examples
mysqlstored-proceduresmysql-workbenchmysql-error-1064

MIssing semicolon error in stored procedure mysql workbench


HI I am new to mysql and trying to update table through stored procedure.I am getting "missing semicolon error.I tried everything but I couldn't able to understand why is this happening.

procedure:

DROP PROCEDURE IF EXISTS abc;
use smartdata;
DELIMITER $$

CREATE PROCEDURE abc(IN datasourceId int)
begin

        update DM_Sample_Search_Param_Disposition_Type set DM_Sample_Search_Param_Disposition_Type.Active = 0
        From DM_Sample_Search_Param_Disposition_Type dm_ss_param_cl
        left join DM_Sample_Search_Param dm_ss_param on dm_ss_param_cl.DM_Sample_Search_Param_id =dm_ss_param.DM_Sample_Search_Param_id
        left join DM_Sample_Store dm_ss on dm_ss.DM_Sample_Store_Id=dm_ss_param.DM_Sample_Store_Id
        where dm_ss.Datasource_Id=datasourceId;

end $$
DELIMITER //

Error in near below line:

set DM_Sample_Search_Param_Disposition_Type.Active = 0

where "Active" is tinyint in the table.Please help


Solution

  • MySQL uses a different syntax for update than MSSQL: update ... join .. set ... where ...

    update DM_Sample_Search_Param_Disposition_Type dm_ss_param_cl
    left join DM_Sample_Search_Param dm_ss_param on dm_ss_param_cl.DM_Sample_Search_Param_id =dm_ss_param.DM_Sample_Search_Param_id
    left join DM_Sample_Store dm_ss on dm_ss.DM_Sample_Store_Id=dm_ss_param.DM_Sample_Store_Id
    set DM_Sample_Search_Param_Disposition_Type.Active = 0
    where dm_ss.Datasource_Id=datasourceId;