RE: bulk collect into ... limit N
Date: Wed, 1 Jul 2009 10:25:41 -0400
You can rely on %NOTFOUND at the end of the loop as it will work 100% of the time, but I agree that it should be used. I've attended several of Steven Feurstein presentations where he explains that since %NOTFOUND was/is typically used at the beginning of the a standard (non bulk collect limit n) loop it is an easy mistake to make. If it is put at the beginning some of the data will not be processed. I also agree the %count reads better.
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org]
On Behalf Of Tony Adolph
Sent: Wednesday, July 01, 2009 1:22 AM
To: Herald ten Dam
Subject: Re: bulk collect into ... limit N
The article by Steven Feuerstein (thanks Denis and Herald) says don't rely on %NOTFOUND when using bulk collect :
When you are using BULK COLLECT and collections to fetch data from your cursor, you should never rely on the cursor attributes to decide whether to terminate your loop and data processing.
It doesn't say why it works at the end of the loop though, but I'll leave it there. Just use %count on the collection instead. It reads better any way I reckon.
Thanks for all the feedback,