Oracle migrates fields between tables through the Stored Procedure

Source: Internet
Author: User

Oracle implements field migration conditions between tables through the stored procedure: two tables: ITPUB_TEST1 field id, value ITPUB_TEST2 field id, funcid, action ITPUB_TEST2 funcid associated with id in itpub_test1. Task: migrate the action content in ITPUB_TEST2 to the value field corresponding to itpub_test1. (Funcid id)

[SQL] create or replace procedure transfer as Cursor cursor is select funcid, action from ITPUB_TEST2; myVar varchar2 (50); begin for myVar in cursor LOOP begin dbms_output.put_line (myVar. funcid); dbms_output.put_line (myVar. action); if (myVar. funcid! = 0) then dbms_output.put_line ('OK'); update ITPUB_TEST1 set value = myVar. action where id = myVar. funcid; end if; end LOOP; commit; end;

 

[SQL] [SQL] Run: [SQL] exec transfer ();

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.