• Welcome, Guest. Please login.
May 07, 2021, 11:06:08 PM


Welcome to the SQLitening support forums!

A thought

Started by Mark Strickland, March 21, 2008, 12:28:01 AM

Previous topic - Next topic

Mark Strickland

As I have started to convert some live code with Cheetah I can see the need for a minor enhancement.

When doing a SELECT it would be useful to know how many rows exist in the record set before trying to navigate the set.  This would be especially useful when looking for a "direct hit" on a single row in a table.

Would it be hard to add a new parm in the sql3_select function?  Or maybe a new function that would return the row count for a specified record set.

Mark Strickland, CISSP

Paul Squires

I answered a question similar to yours a little while ago. You can add a COUNT to your SELECT in order to get the number of rows prior to iterating the recordset. Here is a modified version of the example I used:

sSQL = "SELECT COUNT(RowID) AS RowCount FROM dvd;"
   If sql3_select( hSession, sSQL, rs, 1000 ) = 0 Then
      MsgBox "RowCount: " & sql3_rsColText( hSession, rs, "RowCount", 0 )
      Do Until sql3_rsFetch( hSession, rs ) <> %SQL3_EOF
           ' Get the data from each row in the retrieved record
   End If
   If rs Then sql3_rsDestroy hSession, rs

Mark Strickland

OK --- I saw that one but I was being lazy  :P

SQL Tools from Perfect Sync returns the record count after a SELECT and from a coding style point of view it made sense to me.

I think I will work on a set of wrappers to handle this type of thing and it will be fine.

Thanks for the reply.  I am not really trying to "make work" for you.    ;)
Mark Strickland, CISSP