Subject Re: [ib-support] How many rows were affected?
Author Paul Reeves
Nando Dessena wrote:
> Ann,
> > >if I issue an update or delete statement inside a stored procedure, and
> > >want to know how many rows the statement has affected *from within the
> > >SP code*, is there a way?
> > >I know the information is accessible via the API, I just need it in the
> > >SP.
> >
> > Given the way the engine works, updating or deleting in a for select
> > loop is very nearly as fast as a mass update or delete. Since the
> > procedure succeeds or fails as a unit, you get the same statement
> > level error unwind. So, just do a for select and keep a count.
> thanks; I assume this will be faster that doing a select count() first
> and then the actual delete, isn't it?

It has to be, by nature of the way count works - it will count each row - so if
the delete goes ahead you will touch each row twice.


Paul Reeves
taking InterBase further