时间:2021-07-01 10:21:17 帮助过:13人阅读
##创建出证订单表中存证编号为null的情况下更新所用存储过程
create procedure evi_order_refs_eid_deal()
begin
declare original_eviId varchar(50);
declare evidenceEid varchar(50);
declare done int default 0;
declare mark varchar(2);
declare eid_value varchar(50);
declare type_value int default 0;
declare eid_mark varchar(50);
# declare existence boolean ;
##
declare cur cursor for select eviId from evi_order_refs where evidenceEid is null order by createTime desc;
##异常处理(触发sql语句失败,执行结束)
declare continue handler for sqlstate ‘09000‘ set done = 1;
open cur;
##取出游标值至变量中
fetch next from cur into original_eviId;
repeat
if not done then
select type into type_value from osv_service_evidence where id = original_eviId;
#逻辑判断,如果eviId确实在存证表中无记录,直接忽略该条出证记录
select e.eid into eid_value from osv_service_evidence e where id = original_eviId;
#逻辑判断,如果eviId确实在存证表中无记录,直接忽略该条出证记录
if(0 =type_value|null = eid_value) then fetch next from cur into original_eviId;
end if;
if type_value =40 then set mark = ‘O‘;set eid_mark=concat(mark,eid_value);update evi_order_refs set evidenceEid = eid_mark where eviId = original_eviId;
elseif type_value =11 then set mark = ‘S‘;set eid_mark=concat(mark,eid_value);update evi_order_refs set evidenceEid = eid_mark where eviId = original_eviId;else set done = 0;
end if;
end if;
#if(done = 1) then leave cur;
##重新抓取数据进入循环
fetch next from cur into original_eviId;
##结束循环
until done end repeat;
##关闭游标
close cur;
end ;
mysql存储过程嵌套循环并分页处理数据
标签:抓取 efault sqlstate 取数 升级 分页查询 公司 font end