Lazarus

Programming => Databases => Topic started by: Cigydd on September 30, 2009, 06:23:13 pm

Title: Float truncated in SQLite
Post by: Cigydd on September 30, 2009, 06:23:13 pm
Hi everybody,

I experience troubles using SQLite query. :'(

Accessing fields defined as real in SQLite, the stored values get truncated to whole numbers (integers).

Lazarus 0.9.27/fpc 2.2.2, Laz. 0.9.26.2.

Is there someone who would know how do I need to define the field in SQLite to get real floating point values? Is this a bug or not? Please help me.
Title: Re: Float truncated in SQLite
Post by: davesimplewear on October 01, 2009, 12:13:32 am
One way is to use the numeric field, define the numbers by numeric(6,2) for example for currency operations or change either of those values to suit your needs or use float instead of real.
Title: Re: Float truncated in SQLite
Post by: Cigydd on October 01, 2009, 11:59:54 am
Thank you :)
I think that float also gets truncated. But I'll test it.
Fields defined as numeric(x,y) get divided by 10,000. I can only work it around by multiplying the values. Again, is it a bug or not?
Title: Re: Float truncated in SQLite
Post by: Cigydd on October 01, 2009, 04:06:46 pm
I have already tested it. Changed all real fields to floats but still everything gets truncated.  :(
Title: Re: Float truncated in SQLite
Post by: Cigydd on October 02, 2009, 01:14:23 pm
I think it's the regional setting. We have a decimal comma instead of point. I send the numbers with the comma to the SQL command and so it becomes truncated. So it has a merely prosaic reason.
Excuse me for annoying.
Title: Re: Float truncated in SQLite
Post by: Cigydd on October 02, 2009, 03:34:58 pm
Strangely enough, it still persists, even when I use the decimal point.
Edit:
And even strangelier, it's gone. Sorry for the noise.
Title: Re: Float truncated in SQLite
Post by: clauslack on October 03, 2009, 03:52:44 pm
I have a similar problem.
In what control do you see the number truncated ?

With a SQL Select to Firebird Database, the float field in TDBEdit  show only 2 digits(60), but in TDBGrid show fine the number.(606)

For me is TDBEdit  issue,

Under Lazarus 0.9.29 svn 21445. fpc 2.3.1 svn 13383.

I will do more check with the last lazarus svn for report in bugtracker.
Regards
Title: Re: Float truncated in SQLite
Post by: Cigydd on October 03, 2009, 04:41:37 pm
For me, the truncated numbers were only got from TQuerys and saved into a log file. No specific control. In my case it was my mistake - now I'm aware that the most probable cause was that I didn't convert the numbers from decimal comma to decimal point.
Title: Re: Float truncated in SQLite
Post by: clauslack on October 03, 2009, 05:35:02 pm
In my case the problem is not decimal comma or decimal point.
DBEdit show only 2 digits after
-
SQLTransaction.Commit
SQLTransaction.StartTransaction.
--
DBGrid in the same transaction that DBEdit show fine the float number.

I don't know if is a SQLdb issue(fpc) or TDBEdit issue(LCL).
I will do more test.


TinyPortal © 2005-2018