After the quantity check, the procedure tries to fetch next from the cursor, but if the rollback occurred, this causes an error because the rollback closed the cursor.
If the cursor is closed using the close statement before the return of the SQL procedure, the cursor result set will not be returned to the caller or client application.