Database Loop

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Database Loop

Post by jesse » Sat Jun 25, 2011 7:42 pm

I am trying to construct a repeat loop that can loop through my database results but I'm not sure how to get
the data in the loop. Here is what I have so far.

This appears to return the id of the query livecode has assigned it. but from there i'm not sure how to get the data.

Code: Select all

   put revQueryDatabase(conID,tSQL) into tCursor
put revDataFromQuery(tab,return,conID,tSQL) into tRecords
then i have my repeat loop which was using revDataFromQuery but I can't refer to the columns by name using revDataFromQuery
so its my understanding I need to change over to using revDataFromQuery to revQueryDatabase but I can't seem to find any
examples using it in a repeat loop so I'm not sure how to actually loop the data and refer to the columns in the loop.

Code: Select all

     repeat with i = 1 to the number of lines of tRecords
        answer line i of tRecords
end repeat
Once again if anyone can come to my rescue that would be great!
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Contact:

Re: Database Loop

Post by dglass » Sat Jun 25, 2011 8:04 pm

Since you have cursor/recordset (tCursor) your loop would look like this:

Code: Select all

repeat until revQueryIsAtEnd(tCursor)

....do whatever you need to do with the current record           

revMoveToNextRecord tCursor
end repeat

jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Re: Database Loop

Post by jesse » Sun Jun 26, 2011 1:15 am

thank you again. your really great help!
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392

Post Reply