Navigating through SQL Data

Peter Haworth pete at lcsql.com
Thu Dec 12 14:08:19 EST 2013


Hi Skip,
You might want to think about using revQueryDatabase to create a database
cursor. The processing for your buttons then becomes:

First: revMoveToFirstRecord
Prev: revMoveToPreviousRecord
Next: revMoveToNextRecord
Last: revMoveToLastRecord

It's a bit more longwinded to display the data from your query because you
have to use revDatabaseColumnNamed to get each column from the current
record in the cursor.  Also watch out for the fact that the cursor is
zero-indexed not 1.

If you stick with revDataFromQuery, you would need to keep the current line
number of tRecords somewhere (say tLinenum), then:

First: put 1 into tLinenum
Prev: if tLinenum> 1 then subtract 1 from tLineNum
Next: if tLinenum < the number of lines in tRecords then add 1 to tLineNum
Last: put the number of lines in tRecords into tLinenum

Then use "line tLinenum of tRecords" to get your data.  You can also
disable/enable the buttons depedning on where you are in tRecords, for
example, you'd disable Prev if you're at record #1 so you don't need the
check in the Prev button for tLineNum>1.

Pete
lcSQL Software <http://www.lcsql.com>


On Thu, Dec 12, 2013 at 10:00 AM, Magicgate Software - Skip Kimpel <
skip at magicgate.com> wrote:

> What is the best way to navigate through records retrieved through this
> method:
>    put revDataFromQuery(tab,return,tResult,tSQL) into tRecords
>
> I am using arrow buttons for first, last, next and previous.  Need to
> figure out the code for those buttons.....
>
> Thanks in advance!
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list