How to manage large SQL data sets - reply 2

Kay C Lan lan.kc.macmail at gmail.com
Fri May 5 20:54:31 EDT 2006


On 5/6/06, mfstuart at cox.net <mfstuart at cox.net> wrote:
>
> How do I get the data into a table list on the card?



As David has indicated all the info is in the Docs.

>From the Rev Docs

revDatabaseColumnNamed(recordSetID,columnName[,holderVariable])

revDatabaseColumnNamed(myResults,"LASTNAME")
revDatabaseColumnNamed(zipSearch,"CARRIER",foundCarriers)

So you'd do something like this:
(be careful of line wraps - there should be only 5 lines of code

----------
put revOpenDatabase("MySQL",,"names",tMyUserId,tMyPassword) into tMyDbId


put revQueryDatabase(tMyDbId, "SELECT * FROM names ORDER BY LastName,
FirstName") into tMyCursorID

revMoveToFirstRecord tMyCursorID

put revDatabaseColumnNamed(tMyCursorID,"FirstName") into field "FirstName"
of Stack "Employee Data"

put revDatabaseColumnNamed(tMyCursorID,"LastName") into field "LastName" of
stack "Employee Data"
----------

Obviously this is not optimised, but as a tip, if you name your Rev fields
and SQL columns exactly the same, it makes debugging and the use of repeat
loops a whole heap easier:-)

The other 'movement' functions are - from the Docs

revMoveToLastRecord tMyCursorID
revMoveToPreviousRecord tMyCursorID

Depending on on how much data you want to show in your table you would
simply do something like, remembering that table data is only tab delimited
info:

7 lines of code
----------
revMoveToFirstRecord tMyCursorID

repeat with tMyCounter = 1 to 50 --or any other suitable number

put revDatabaseColumnNamed(tMyCursorID,"FirstName") & tab into line
tMyCounter of tMyData

put revDatabaseColumnNamed(tMyCursorID,"LastName") after line tMyCounter of
tMyData

revMoveToNextRecord tMyCursorID

end repeat

put tMyData into field "Data Display" of stack "Employee Data"
----------

You could easily set up two button, 'Previous 50', 'Next 50' that would
cycle through the data using a similar repeat loop.

HTH



More information about the use-livecode mailing list