Oracle Cursor Small test

Source: Internet
Author: User

It is sometimes necessary to modify the data in large areas, this time with a circular statement efficiency is not high. The cursor seems like a good choice when the temporal table doesn't meet the point-to-point modifications (PS: It's like a cursor is a loop)

Now there are two tables T1 (Ryid number,name nvarchar2 (), salary number,paydate date ...) To keep the employee's monthly salary.

T2 (Ryid number,paysalary number) Monthly payroll is now adding paysalary from T2 to T1

Can be implemented directly with update;

Now uses Oracle's for cursors to implement

1 --Defining Cursors2 Declare3          cursorId--Cursor name4           is5                 Selectryid,salary from T2; --Insert the required content into the cursor 6R_ID ID%RowType--sort of like rows in DS.7 8 begin9      forr_idinchID LoopTen         UpdateT1SetT1.salary=r_id.paysalary--Content One             whereT1.ryid=R_id.ryid; A     EndLoop; - End;

Other types of cursors are similar.

The content section cannot output content with a SELECT statement.

As a memo

Http://www.cnblogs.com/sc-xx/archive/2011/12/03/2275084.html Reference Address

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.