Databases: problem stepping through records with BLOBs

Devin Asay devin_asay at byu.edu
Thu Apr 13 17:30:10 EDT 2006


Has anyone run into this?

I am sending a query to a database and then I want to step through  
the records. I'm doing it like this (watch for line wrapping):

   put "26,54,110,111,250,259,272,314,149" into tTermListData --  
preload for testing
   put "SELECT item_index,item_code FROM vocablist WHERE item_index  
IN (" & tTermListData & ")" into tQuery
   put revQueryDatabase(connID,tQuery) into tRS
   put revNumberOfRecords(tRS) into curRecCount -- this returns the  
correct number
   repeat
     put revCurrentRecord(tRS) into curRec -- this increments as  
expected
     put revDatabaseColumnNamed(tRS,"item_index",tItemNum) -- always  
shows the first record!
     put revDatabaseColumnNamed(tRS,"item_code",tItemCode) -- always  
shows the first record!
     if revCurrentRecordIsLast(tRS) then exit repeat -- works as  
expected
     revMoveToNextRecord tRS
   end repeat
   revCloseCursor tRS

Long story short, it doesn't work. But if you do this:

   put "26,54,110,111,250,259,272,314,149" into tTermListData --  
preload for testing
   put "SELECT item_index,item_code FROM vocablist WHERE item_index  
IN (" & tTermListData & ")" into tQuery
   put revQueryDatabase(connID,tQuery) into tRS
   put revNumberOfRecords(tRS) into curRecCount -- this returns the  
correct number
   repeat
     put revCurrentRecord(tRS) into curRec -- this increments as  
expected
     put revDatabaseColumnNamed(tRS,"item_index") into tItemNum --  
always shows the first record!
     put revDatabaseColumnNamed(tRS,"item_code") into tItemCode --  
always shows the first record!
     if revCurrentRecordIsLast(tRS) then exit repeat -- works as  
expected
     revMoveToNextRecord tRS
   end repeat
   revCloseCursor tRS

It does work. Fine, I can work around it. (I've also bugzilla'd this,  
BZ # 3525)

Here's where a problem arises: If the data I want to retrieve is  
binary, and I use revQueryDatabaseBLOB() to retrieve the records, the  
only way I can successfully retrieve the binary data is by using the  
first form of the function: revDataBaseColumnNamed(tRS,"<binary data  
field>",tImageData), which, as we've seen, only retrieves the first  
record. If I use the second form, put revDataBaseColumnNamed 
(tRS,"<binary data field>") into tImageData , I only get the first  
few characters of the binary data.

Any advice on how to get out of this conundrum?

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list