• Welcome, Guest. Please login.
 
September 17, 2019, 01:59:35 pm

News:

Welcome to the SQLitening support forums!


How many record

Started by Robert Sarrazin, March 01, 2008, 12:45:09 am

Previous topic - Next topic

Robert Sarrazin

March 01, 2008, 12:45:09 am Last Edit: March 01, 2008, 01:42:04 am by Robert Sarrazin
Hi,

I try to figure out how many record or ROW in the data base.

This is the File:
using SQLite version 0009

                 sSQL = "CREATE TABLE [dvd] ( "   & _
                        "[num] INTEGER PRIMARY KEY, "  & _
                        "[titre] CHARACTER (30), "          & _
                        "[acteur] CHARACTER (25), "          & _
                        "[lang] NUMERIC, "         & _
                        "[form] NUMERIC, "        & _
                        "[type] CHARACTER (8 ), "          & _
                        "[image] CHARACTER (12), "          & _
                        "[comment] CHARACTER (20)" & _
                        ");"
                        errcode = sql3_exec( hSession, sSQL ) 

the num is my key

I try this.

test1       x = sql3_rsColCount( hSession, rs ) ' THAT WORK OK GIVE BACK Column NUMBER
              x = sql3_rsRowCount( hSession, rs ) ' OPP Missing declaration: SQL3_RSROWCOUNT

test 2      sSQL = "SELECT * FROM dvd WHERE " + "max(num)"+ ";"
test 3      sSQL= "SELECT MAX(num) FROM dvd;"
test 4      sSQL= "select COUNT(*) from dvd;"
test 5      sSQL = "SELECT count(num) FROM dvd;"


              errcode = sql3_select( hSession, sSQL, rs, 1000 )
              DO UNTIL sql3_rsFetch( hSession, rs ) = %SQL3_EOF
                    x= sql3_rsColInt( hSession, rs, "num", 0 ))
              LOOP                                           

              MSGBOX STR$(x)

I got the result now by reading with select like %% that read
record by record to the end of the file and I got the last record ( num ).
I try to find a better way to program that.

Thank for your time. ::)


Paul Squires

I think that you are on the right track. Here is an easy way to get the record count:


   sSQL = "SELECT COUNT(RowID) AS RowCount FROM dvd;"
   If sql3_select( hSession, sSQL, rs, 1 ) = 0 Then
      If sql3_rsFetch( hSession, rs ) <> %SQL3_EOF Then
         MsgBox "RowCount: " & sql3_rsColText( hSession, rs, "RowCount", 0 )
      End If   
   End If
   If rs Then sql3_rsDestroy hSession, rs