Create or Replaceprocedure Update_recordcode is the cursor Location_data is a SELECT * from location where remark in (' 952701 ', ' 9527008 ', ' 952705 ');--Affirming the cursor servicecode number:=1; Begin for L in Location_data loop --Traversal cursor BEGIN- -Business process 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--exception handling when No_data_found and then inserts into Serial_code (Area_code, Loc_type,cur_number) VALUES ( l.area_code,l.type,1); End; End Loop; Commit END Update_recordcode;
Oracle stored procedure + cursor processing SELECT data