Sql%rowcount in Oracle

Source: Internet
Author: User
Tags rowcount

Sql%rowcount is used to record the number of modified bars, as if you were prompted to delete xx rows after executing the delete from Sqlplus, this parameter must be placed between a modification statement and a commit, otherwise you will not get the correct number of modified rows.

For example:
Sql> declare n number;
2 begin
3 INSERT INTO Test_a Select level LV from dual connect by level<500;
4 N:=sql%rowcount;
5 commit;
6 dbms_output.put_line (n);
7 End;
8/
499

PL/SQL procedure successfully completed.
Sql> declare n number;
2 begin
3 INSERT INTO Test_a Select level LV from dual connect by level<500;
4 commit;
5 N:=sql%rowcount;
6 dbms_output.put_line (n);
7 End;
8/
0

PL/SQL procedure successfully completed.
Xxxxxxxxxxxxx

If I execute 3 SELECT statements in a row
Then call Sql%rowcount, and the result is the number of the last select. To count all, you can use three variables to receive Sql%rowcount, and then add, but it seems that the direct select of the wording cannot use Sql%rowcount.

Sql%rowcount in Oracle

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.