SQL % rowcount

Source: Internet
Author: User

Number of lines deleted from the output bound to the variable

Execute in PLSQL command window. By default, the value of the bound variable is printed.

SQL> variable rows_deleted number

SQL> declare
2 v_id number: = 11;

 

4 begin
5 delete from building where id = v_id;
6: Rows_deleted: = SQL % rowcount;
7 end;
8/
 
PL/SQL procedure successfully completed
Rows_deleted
---------
0
 

Normal variables cannot be output by printing

SQL> variable rows_deleted number

SQL> declare
2 v_id number: = 11;

 

4 begin
5 delete from building where id = v_id;
6Rows_deleted: = SQL % rowcount;
7 end;
8/
 
PL/SQL procedure successfully completed

Only prompts that the process is executed. to output this variable, you must output it through the dbms_output process.

 

Run in sqlplus

SQL> variable rows_deleted number
SQL> declare
2 v_id number: = 11;
3 begin
4 Delete from building where id = v_id;
5: rows_deleted: = SQL % rowcount;
6 end;
7/

The PL/SQL process is successfully completed.

SQL> Print rows_deleted

Rows_deleted
------------
0

 

The following statement is also executed in the Command window of PLSQL

SQL> variable rows_deleted number
SQL> declare
2 type v_id_table_type is table of Building. ID % type;
3 v_id_table v_id_table_type;
4 begin
5 select ID bulk collect into v_id_table from building where rownum <= 10;
6: rows_deleted: = SQL % rowcount;
7 end;
8/
 
PL/SQL procedure successfully completed
Rows_deleted
---------
10

 

 

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.