#打开之前定义的游标OPENC_WARRANTY;#loop_label:LOOP#IFno_more_departmentsTHEN#LEAVEloop_label;#ENDIF;#取出每条记录并赋值给相关变量,注意顺序FETCHC_WARRANTYINTOw_orderid,w_...
#打开之前定义的游标
OPEN C_WARRANTY;
#loop_label: LOOP
#IF no_more_departments THEN
# LEAVE loop_label;
#END IF;
#取出每条记录并赋值给相关变量,注意顺序
FETCH C_WARRANTY INTO w_orderid, w_ordertime, w_member_id;
#循环语句的关键词
REPEAT
#调用流水号
CALL proc_serial_number(w_warranty_id);
SET no_more_departments=0;
#保修卡主表添加
CALL `proc_warranty`(w_warranty_id,w_orderid,w_ordertime,w_member_id);
#取出每条记录并赋值给相关变量,注意顺序
FETCH C_WARRANTY INTO w_orderid, w_ordertime, w_member_id;
#循环语句结束
UNTIL no_more_departments END REPEAT;
#END LOOP;
#关闭游标
CLOSE C_WARRANTY;
SET no_more_departments = 0;
#打开明细游标
OPEN C_WARRANTY_DETAIL;
#取出每条记录并赋值给相关变量,注意顺序
FETCH C_WARRANTY INTO wd_warranty_id, wd_item_id, wd_order_id,wd_obj_id,wd_product_id,
wd_goods_id,wd_type_id,wd_bn,wd_pn,wd_name,wd_nums,wd_sendnum,wd_addon,wd_item_type;
#循环语句的关键词
REPEAT
#生成保修卡明细
CALL `proc_warranty_detail`(wd_warranty_id, wd_item_id, wd_order_id,wd_obj_id,wd_product_id,
wd_goods_id,wd_type_id,wd_bn,wd_pn,wd_name,wd_nums,wd_sendnum,wd_addon,wd_item_type);
#取出每条记录并赋值给相关变量,注意顺序
FETCH C_WARRANTY INTO wd_warranty_id, wd_item_id, wd_order_id,wd_obj_id,wd_product_id,
wd_goods_id,wd_type_id,wd_bn,wd_pn,wd_name,wd_nums,wd_sendnum,wd_addon,wd_item_type;
#循环语句结束
UNTIL no_more_departments END REPEAT;
CLOSE C_WARRANTY_DETAIL;
展开