Last record of a cursor?
Bob Sneidar
bobsneidar at iotecdigital.com
Fri Sep 17 19:33:00 EDT 2021
Okay something is not right with the API! First, my query in my script is set to:
SELECT * from files where siteid = '1659'
If I run this in mySQLWorkbench, I get one record, so I know the query works. Also, I know the cursor contains records, because as I step through the loops which get the column values, I can see the vlaues in the variables populate when I use:
put revDatabaseColumnNumbered(pCursorID, i) into tColumnValue
Here is the rub though. The first record of a cursor is 0. ZERO!!! And if there is only one record, guess what the LAST record is??? ZERO!!!!!
Does that make the least bit of sense to ANYONE??? There is no call that I can find to get the number of records of a cursor! Therefore I can NEVER TELL if a cursor contains any records.
If anyone has a method for doing so, your help will be very much appreciated.
Bob S
> On Sep 17, 2021, at 16:04 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Hi all.
>
> I am trying to discern between when I have an empty cursor, and when I have reached the last record of a cursor.
>
> I have noticed that if I query a database that returns no results, I still get a cursor ID, so I cannot test for a cursor ID. So after my loop to convert a cursor to an array, I check to see if I am on the last record by using put revCurrentRecord(pCursorID) into tLastRecord, then testing to see if it returns 0, which it will if the cursor is empty.
>
> But it seems that if I am already on the last record of the cursor, then I use revMoveToNextRecord pCursorID, revCurrentRecord ALSO RETURNS 0! So now I am left without a way to tell if the cursor is empty, or if otherwise, I have reached the last record.
>
> How is this done?? Normally I use sqlYoga so these things are spared me, but in this instance I am using the native API calls.
>
> Bob S
>
>
> _______________________________________________
> 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