Oracle stored procedure + cursors handle SELECT data

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.