parse a record set
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
parse a record set
Hello. New to RunRev and wanting to implement the following:
I have connected to a MySQL db/table and made a query. I need to loop through the result continuously displaying one field in a text field in stack one. The data displays on the same field at great speed until the user clicks on a button that makes it stop. The start and stop part I have solved. What I need is the DB part to loop though the query result. Can anyone point me to an example that does just that? Not data grids or lists because that moves differently. Thanks in advance.
I have connected to a MySQL db/table and made a query. I need to loop through the result continuously displaying one field in a text field in stack one. The data displays on the same field at great speed until the user clicks on a button that makes it stop. The start and stop part I have solved. What I need is the DB part to loop though the query result. Can anyone point me to an example that does just that? Not data grids or lists because that moves differently. Thanks in advance.
Re: parse a record set
Are you sure you need a "record set" ?egn wrote:Hello. New to RunRev and wanting to implement the following:
I have connected to a MySQL db/table and made a query. I need to loop through the result continuously displaying one field in a text field in stack one. The data displays on the same field at great speed until the user clicks on a button that makes it stop. The start and stop part I have solved. What I need is the DB part to loop though the query result. Can anyone point me to an example that does just that? Not data grids or lists because that moves differently. Thanks in advance.
For large number of lines, I would rather use the revDataFromQuery command.
Doc : Gets records from a database according to a SQL query and places the resulting data in a variable, without creating a record set (database cursor).
put revDataFromQuery(,,dbID,dbSQL) into toParse
You receive all the lines given by your query. And then after you're free to to do whatever you want (loop to display each line in a field, until the mouse is clicked or whatever else).
Re: parse a record set
Thanks for the info.
I have not been able to implement this. It returns what seems to me like a big variable with all values in it. What I need is an array and some way to step through it one by one and if I reach the end then it will loop back to the first item in the array.
I've looked at the User's Guide but that just lists the commands available for DB access and no examples. The Dictionary has a few lines on the syntax but no complete examples. I'm afraid I'm stuck at this point and betting the solution is very simple!
Any example or webpage that has one would be of great help.
Tks.
I have not been able to implement this. It returns what seems to me like a big variable with all values in it. What I need is an array and some way to step through it one by one and if I reach the end then it will loop back to the first item in the array.
I've looked at the User's Guide but that just lists the commands available for DB access and no examples. The Dictionary has a few lines on the syntax but no complete examples. I'm afraid I'm stuck at this point and betting the solution is very simple!
Any example or webpage that has one would be of great help.
Tks.
Re: parse a record set
Okay. With the script :egn wrote:Thanks for the info.
I have not been able to implement this. It returns what seems to me like a big variable with all values in it. What I need is an array and some way to step through it one by one and if I reach the end then it will loop back to the first item in the array.
I've looked at the User's Guide but that just lists the commands available for DB access and no examples. The Dictionary has a few lines on the syntax but no complete examples. I'm afraid I'm stuck at this point and betting the solution is very simple!
Any example or webpage that has one would be of great help.
Tks.
You'll get :put "SELECT customerID, countryName FROM mytable WHERE countryname='germany' " into dbSQL
put revDataFromQuery(,,dbID,dbSQL) into toParse
1 line per record
each column being separated by tabulation
After, it's rather easy to parse :
Code: Select all
set itemdelimiter to tab
repeat with i = 1 to the number of lines of toParse
put item 1 of line i of toParse into field "myfield" -- or do something else, or put into an array
end repeat
Code: Select all
on mouseStillDown
global theRecord,toParse
if theRecord = the number of lines of toParse then put 1 into theRecord --we go back at first record
put line theRecord of toParse into field "myfield"
add 1 to theRecord
end mouseStillDown
Each of the records will be displayed into the field "myfield" while the mouse button is down.
It's dirty code, it's not array, but I think you'll get the point.
(download the little stack with the example)
- Attachments
-
- TEST1.zip
- (746 Bytes) Downloaded 324 times
Re: parse a record set
Thanks! What did it was the "put item 1 of" .....
In my query I select 2 fields and the repeat I had was showing both values at the same time.
I am now using the item number to get every field of each record that I want to display and when the repeat stops I can have it put item 2 into another field to show the second data item from the table. I just did not know how to pick one specific field! I find I'm having to relearn ways of doing things in RunRev!
Again, thanks a million for your help.
In my query I select 2 fields and the repeat I had was showing both values at the same time.
I am now using the item number to get every field of each record that I want to display and when the repeat stops I can have it put item 2 into another field to show the second data item from the table. I just did not know how to pick one specific field! I find I'm having to relearn ways of doing things in RunRev!
Again, thanks a million for your help.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: parse a record set
FYI - there is an example of converting a database cursor to an array in the Data Grid manual in case you want to see another approach.
http://lessons.runrev.com/spaces/lesson ... Grid-Array
http://lessons.runrev.com/spaces/lesson ... Grid-Array
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder