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 consecutively
and then call Sql%rowcount, 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 like the direct select of the wording cannot use Sql%rowcount.