Quote:
Originally posted by lakshmi arvind
requirement is to determine number of rows returned by a cursor. this number of rows should be determined before executing the fetch cursor stmt itself.
in oracle sql , there are attributes for cursors such %rowcount(), which will determine the number of rows retrieved when a open cursor is executed.
example flow
declare cursor c1 for select * from table
open c1
if c1%rowcount() > 200
then exit.
Is some similiar attributes present like this in DB2.
thanks for your reply also.
|
First of all, I don't see what is wrong with executing FETCH. I believe it's OPEN that takes most time, not FETCH, so if you intend to save time/resources then I don't think avoiding the FETCH will help you a lot.
However, if your database has relatively current statistics AND your query does not contain any WHERE conditions or groupings then you can use
SELECT CARD FROM SYSCAT.TABLES WHERE TABNAME='table_name'
to determine the total number of rows in the table.