Posted: Sun Apr 29, 2012 12:23 am Post subject: Number of records fetched in a cursor
I need to know the number of records selected by a cursor before processing the first record fecthed by cursor. Does any variable of SQLCA will store the number of records by the cursor ?. Any other possible way apart from using select count(*) with the cursor where clause condition ?
first of all, db2 has rows and columns. files have records and fields.
secondly, your terminology needs to improved.
what you want to know is:
is there a way to determine the size of a result set other than count(*)?
the sqlerrcd3 will provide you with the number of rows involved with an
for each invocation of SQL
if you have 3 rows in the result set and you do single FETCHs, each FETCH
(if sqlcode = +000)
will return +1 in sqlerrcd3.
by the way, sqlerrcd3 functions for both cursors and singleton selects.
i would question why one would need the count of the result set
prior to actually FETCHing rows.
sounds like poor/inexperienced programming
i am moving this thread to INTERVIEW QUESTIONS as the topic fits there better.
db2 application programming forum is for db2 problems for more advanced topics
than posed by beginners/INTERVIEW Questions. _________________ Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum