Home   Archive   Permalink



Finding size of SQL result

I have this program that extracts about 30,000 records out of an SQL Server database, and the operation is quick but not that quick, so I have the following procedure for reassuring the operator that things are moving along. It works fine, but is a bit old school. I thought that flashing a progress bar might be nice, but it seems that in order to operate the progress bar I have to know in advance how many records I will be processing. I am not seeing a way to do that with the REBOL ODBC interface. I insert the SQL into a command port or whatever it is called, and pick off the results one at a time, but I don't know how many I ultimately will be picking. Does anyone know if that information (the number of records returned) can be determined before actually processing them?
    
Thank you.
    
Old-school solution follows:
    
insert VISION-CMD SQL-PIDLOOKUP ;; Put an SQL string into the ODBC command port.
while [SQL-RESULT: pick VISION-CMD 1] [ ;; Pick off the results one at a time.
     LINE-COUNTER: LINE-COUNTER + 1
     if (0 = (remainder LINE-COUNTER 100)) [
         print [LINE-COUNTER 'Table items processed']
     ]
     ... other processing for a single record
]

posted by:   Steven White       2-Feb-2017/12:54:43-8:00



Perhaps do a count (*) first to get the number of results?
    
The docs on http://www.rebol.com/docs/database.html say to use a solution like
result: copy VISION-CMD
Perhaps result then contains the numbers of rows as its length?

posted by:   iArnold       2-Feb-2017/14:32:09-8:00