Wrap cursor iterator to intercept database errors coming from __next__ m...

...ethod.

This is needed for django-sqlserver driver.

Ticket #22879