Imagine the following table:
id | name | family ---+------+-------- 0 | John | Smith 1 | Mary | Winters 2 | John | Doe
and now the following statement:
UPDATE t SET name = 'John' WHERE id = 0;
This statement in fact would update nothing – as it reflects what already is there. Now all the blogs, manuals and whatsnots said to check
SQL%ROWCOUNT for the number of updated rows. Doing that returns
1 (affected rows – i.e. those the
WHERE clause did match). Let's have another one:
UPDATE t SET family = 'Smith' WHERE name = 'John';
De facto, that would only change the row with id=2, so I want something stating "1 row updated" – but
SQL%ROWCOUNT gives us
2 (again, rows affected).
So here comes the final question: What gives the number of rows changed?