Monday, March 30, 2020

[Mysql][Resolved] mysql stored procedure update not working

While I tried to write UPDATE statement in procedure, no error throw but the field value not updated:

Source:
DELIMITER $$
CREATE PROCEDURE `update_data`(
  in form_no varchar(50),
  in data_str varchar(255),
  out result int
)
begin
  UPDATE forms SET `data_str`=data_str WHERE `form_no`=form_no;
  SET result=0;
end


Finally I found there is some conflict with procedure parameter names and the column names. After rename it works

Correction
DELIMITER $$
CREATE PROCEDURE `update_data`(
  in form_no_in varchar(50),
  in data_str_in varchar(255),
  out result int
)
begin
  UPDATE forms SET `data_str`=data_str_in WHERE `form_no`=form_no_in;
  SET result=0;
end

Reference:
https://stackoverflow.com/questions/14623196/update-statement-in-mysql-procedure-in-not-working

No comments :

Post a Comment