Right now to determine if we have no rows in a resultset, we do the following:
sqlStatement = ...
sqlrs = "%ResultSet"->%New()
sqlrs->Prepare(sqlStatement)
sqlrs->Execute()
if NOT(sqlrs->Next()) then
* we have no rows from this query
...
Other than iterating through the entire resultset and counting it, we
are not seeing how to get the number of rows.
Thanks in advance. --dawn
--
Dawn M. Wolthuis
Take and give some delight today
Thanks in advance. --dawn
I'm just getting back from vacation, but I'll take a swing at this. In
most SQL languages, there isn't really a way to get the number of rows
selected because they do the reads in chunks as needed. I'm not sure if
Cache is the same, but it seems to behave the same way. There are two
ways to get the number of rows:
1. You do a select count(1) from table where.... before you execute your
query. This requires two queries. One to get the count and then one to
get the actual data. Unfortunately, in cases where you are providing a
status bar, this can't be avoided.
2. If you don't need the number of rows selected before processing the
result set, just set a counter variable and increment it in a loop.
myCnt = 0
loop while sqlrs->Next()
myCnt++
repeat
crt myCnt : " row(s) selected."
This is from my experience with other SQL based databases. There may be
a way to set up the ResultSet to fetch all rows on execute and then you
can possibly get the number of rows selected, but I will be honest and
tell you I haven't done the research on that.
Jason
--
You received this message because you are subscribed to the Google Groups "InterSystems: MV Community" group.
To post to this group, send email to Cac...@googlegroups.com
To unsubscribe from this group, send email to CacheMV-u...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CacheMV?hl=en
Thanks. --dawn