SQL%ROWCOUNT is not returning exact rows
Sid_ Z.Mar 6 2008 — edited Mar 6 2008Dear All,
I have written a following block. The cursor has 16 rows. I am updating the print flag in table. All flags gets updated but it is showing only 1 row affected.
I want to know how many rows are being affected by the update statement.
My script goes here.
1 declare
2 cursor c1 is
3 select rowid,a.*
4 from challan_master a
5 where cm_challan_print_flag ='N'
6 and cm_year=2007;
7 begin
8 for i in c1 loop
9 update challan_master
10 set cm_challan_print_flag = 'Y'
11 where rowid=i.rowid;
12 end loop;
13 dbms_output.put_line(to_char(SQL%ROWCOUNT) ||' rows affected');
14 exception when others then
15 dbms_output.put_line(sqlerrm);
16* end;
SQL> /
1 rows affected
PL/SQL procedure successfully completed.
Thanks/Sid