Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: number of rows in cursor?
On Fri, 10 Dec 2004 15:14:28 +0100, Frank Piron <empty_at_zero.nil>
wrote:
>>> You may count the rows explicitly before entering the loop.
>>>
>>> if the cursor statement is: select <projection-clause>
>>> from ....
>>>
>>> you may count with: select count(rowid) into <counter_var>
>>> from ....
>>>
>>> where <counter_var> is some local variable into which you may
>>> store the number of rows the cursor will retrieve.
>>>
>>> --
>>> Frank Piron,
>>> defrankatkonaddot
>>> (leftrotate two)
>> Except the number could change from count to the fetch of the data.
>
>Sure. But this is inevitable.
>
>--
>Frank Piron,
>defrankatkonaddot
>(leftrotate two)
As your advice also effectively selects the data twice, and consequently consumes twice as much resources, I wouldn't recommend this 'workaround' to anyone.
-- Sybrand Bakker, Senior Oracle DBAReceived on Sat Dec 11 2004 - 03:55:56 CST