Android Question ExecQuerySingleResult generates Invalid double: "null"

Gary Milne

Active Member
Licensed User
Longtime User
I'm running a query against SQL to see if a record exists (so it can be updated). The query is quite simple and looks like "SELECT MAX (ShotNumber) FROM SESSION WHERE SessionNumber = 3 AND RallyNumber = 25"

When it does not exist (which is quite common) then I get a java.lang.NumberFormatException: Invalid double: "null"

Other B4A SQL routines will usually say something like "this is a sql exception not an error", but this error does not, so it concerns me.

I have it in a Try Catch loop but if there is a better way I'd like to know what it is.


Thanks for any responses.
 

DonManfred

Expert
Licensed User
Longtime User
without seeing a code it is hard to help.
i would suggest that you first try to check the amount of resulting rows (Recordcount >0) . And only if >0 then you assign the 0th element. To double-check you can check if cursor(0) <> null
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thanks for those responses. I'm using an Int to capture the response but it makes sense that the response would be a string which can be converted to a different type. I'll try that tomorrow.

Many thanks everyone who took the time.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Thanks all, that did the trick.
 
Upvote 0
Top