小编sfd*_*eta的帖子

mysql中的存储过程不起作用

我正在尝试插入一个值,以防未插入,否则尝试更新其某些字段。只使用了一个变量。尽管 ion 调用存储过程,但它显示插入了一行,但未插入值。请帮助我,第一次尝试 SP。

这是我的存储过程

CREATE DEFINER=`root`@`localhost` PROCEDURE `InsertLocation`(in IpAddress varchar(45))
BEGIN     
  if (SELECT count(*) as count 
      FROM mbuzzz.location_byhits 
      where IpAddress = IpAddress
      having count>0)    
  then     
      UPDATE location_byhits SET Hits=Hits+1 where  IpAddress=IpAddress;    
  else     
      insert into location_byhits(IpAddress,Date_current) 
      values (IpAddress,CURTIME());     
  End if ;    
end
Run Code Online (Sandbox Code Playgroud)

mysql sql stored-procedures

2
推荐指数
1
解决办法
4603
查看次数

标签 统计

mysql ×1

sql ×1

stored-procedures ×1