SQLite, Real & Float

johnaaronrose

Active Member
Licensed User
Longtime User
I'm confused about whether to use the Type Real or Float for columns when creating a SQLite database on a PC to be later used by B4A as read only. I have a column which needs to be held with a sign, up to 3 digits before the decimal point and up to 6 digits after the decimal point. I have the requisite validation in the PC app maintaining this database.

Currently I'm using the Float Type when creating the table (in SQL) containing this column. However, when I use the B4A code lblColumn.Text = Cursor.GetString... to retrieve the column's value & display it in a Label view , it seems to be sometimes taking stored values with 6 used decimal places (after the decimal point) and displaying them rounded to 4 decimal places (after the decimal point). Should I change the Type in the SQL Create verb to Real? I looked at the SQL Table Creation example on page 11 of the User's Guide and it has type FLOAT in the Create verb & REAL in the 'spec' underneath.

Or is the problem due to using GetString rather than GetDouble or even some other reason?
 

johnaaronrose

Active Member
Licensed User
Longtime User
Apologies

It's always a pleasure to see a user ignoring the answer you gave him.

Apologies. I forgot to reply because I had some other problems to sort out with my app. I do try to thank people for their help. However, I think that you could phrase your response more diplomatically e.g "Please look at my reply on thread...Did you see it?". Sarcasm tends to lead to flaming. There's an old maxim: Try not to offend someone as you'll never know when you'll need your help.
 
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
Calculation using a number in a Text column


If I use GetDouble, I presume that the resultant variable will accurately hold the column value. Will it display accurately in the lblLatitude view (i.e. with all, and no extra, decimal places used being displayed) using B4A code similar to:
Public Latitude As Double
Latitude = CursorAspect.GetDouble("latitude")
lblLatitude.Text=Latitude

Or is there a better method or view to use?

PS I'd prefer not to define the database's table's Latitude column type as Text because I also want to use it for calculations. Also, It would need modifying the existing PC database maintenance app significantly.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User

That was not the first time, so I lost a bit my diplomatic mood. But all is right now and I agree with your wise maxim.
 
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
Thank you


Thanks, Erel. I will try that out when I'm able to amend the PC app to include database structure changes.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…