- 论坛徽章:
- 0
|
- -- Decide update or insert a data
- delimiter $
- drop procedure if exists Update_Insert $
- create procedure Update_Insert(IN RegDevID INT)
- begin
- select Dec_Base into @base from LastPos where INT_RegDevID=RegDevID;
- select "The value of @base is: ", @base;
- if @base = NULL then
- insert into LastPos(Dec_Base) values('A');
- select "base is NULL";
- else
- select "Update LastPos!";
- update LastPos set Dec_Base = 'A' where INT_RegDevID=RegDevID;
- end if;
- end $
- delimiter ;
复制代码 如上所示,首先我想判断一下RegDevID指向的那一项是否存在,不存在就执行插入操作,否则更新,
通过@base = NULL,可不知为何,无法获得正确结果,请高人指点 |
|