mysql怎么保存一个函数_mysql中我写了一个存储函数 为什么会报错 请指点

delimiter&&createfunctionalarm_info()returnsvarchar(100)readssqldatabegindeclarecountsint(11);declarenint(11);declarefix_timeint(11);declarediffint(11);declareresultvarch...

delimiter &&

create function alarm_info()

returns varchar(100) reads sql data

begin

declare counts int(11);

declare n int(11);

declare fix_time int(11);

declare diff int(11);

declare result varchar(100);

set n=1;

select count(*) into counts from total;

while counts>=n

select tablenames,time_colum,fix_time into names,times,fixs from total where id=n;

select round(time_to_sec(timediff(sysdate(),(select times from names order by id desc limit 1)/60) into diff;

if(diff>fix_time) then result=tablenames;

end if;

n=n+1;

end &&;

delimiter;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select tablenames,time_colum,fix_time into names,times,fixs from total where id=' at line 12

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值