create or replace
PROCEDURE UPDATE_RECORDCODE iscursor location_data is select * from location where remark in('952701','9527008','952705');--申明游标serviceCode NUMBER:=1;
BEGINfor l in location_data loop --遍历游标BEGIN--业务处理UPDATE SERIAL_CODE SET CUR_NUMBER = CUR_NUMBER +1 where AREA_CODE=l.area_code and LOC_TYPE=l.type;select CUR_NUMBER into serviceCode from SERIAL_CODE where AREA_CODE=l.area_code and LOC_TYPE=l.type;update location lu set putrecord_code=(l.area_code||'0'||l.type||lpad(serviceCode,6,0)) where lu.id=l.id; --dbms_output.put_line(ServiceCode);EXCEPTION--异常处理WHEN NO_DATA_FOUND THEN INSERT INTO SERIAL_CODE (AREA_CODE, LOC_TYPE,CUR_NUMBER) VALUES (l.area_code,l.type,1);end;end loop; commit;
END UPDATE_RECORDCODE;
转载于:https://www.cnblogs.com/mengfanrong/p/4367817.html