Re: Last record of a cursor?
Ralph, thanks for the tip. Those handlers were just what I needed. Not sure why I couldn’t find them when I perused the dictionary. Getting daft in my senior years I suppose. I still think it’s inane though, having the first record and last record be 0 when there’s one record. Cannot change it now though. Sent from my iPhone > On Sep 17, 2021, at 16:35, Bob Sneidar via use-livecode > wrote: > > Oh sorry, I posted this just before Ralph replied. Thanks Ralph I will try > your suggestions. > > Bob S > > >> On Sep 17, 2021, at 16:32 , Bob Sneidar wrote: >> >> 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 >>>> 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@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-livecode >> > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Last record of a cursor?
Oh sorry, I posted this just before Ralph replied. Thanks Ralph I will try your suggestions. Bob S > On Sep 17, 2021, at 16:32 , Bob Sneidar wrote: > > 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 >> 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@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Last record of a cursor?
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 > 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@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Last record of a cursor?
Bob, See: revQueryIsAtEnd revnumberofrecords If the number of records is 0 then no results were returned. If revQueryIsAtEnd is true then you're at the end. This will happen after you do an additional revMoveToNextRecord when on the last record. Ralph DiMola IT Director Evergreen Information Services rdim...@evergreeninfo.net -Original Message- From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of Bob Sneidar via use-livecode Sent: Friday, September 17, 2021 7:05 PM To: How to use LiveCode Cc: Bob Sneidar Subject: Last record of a cursor? 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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Last record of a cursor?
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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode