Reading decimal filed from Sqlite database lazarus / 16-Databases ---------------------------------------------------------------------- stone977a · 2010-06-22 00:29 Hi, using Lazarus 0.9.28.2, I created some sample database with simple table. Connection and selecting data works great. For connection I user TSqliteConnection with transaction, for query I use TSQLQuery. I have no problems except when I write select that selects fields defined as Decimal(10,5), I get EDatabaseError: error Invalid field size : 5. Any ideas? Regards, Tone ---------------------------------------------------------------------- Lacak2 · 2010-06-22 02:30 This is because DECIMAL fields are created as TBCDFields and in fields.inc is : class procedure TBCDField.CheckTypeSize(AValue: Longint); begin   If not (AValue in [0..4]) then     DatabaseErrorfmt(SInvalidFieldSize,[Avalue]); end; So ONLY Precision 0..4 is allowed ! (If you change 4 to 5 then error disappears, but only 4 decimal places will be accepted either) I am not sure, but I think, that this is bug (or feature request), so you should report this situation in bug tracker ! (May be that, TFMTBcdField must be implemented to handle correctly DECIMAL and NUMERIC types with precison > 4) ---------------------------------------------------------------------- stone977a · 2010-06-22 22:27 Thanks, and yes, I think this is bug. After changing type to real it worked file, so this is my temporary solution. ---------------------------------------------------------------------- Loesje · 2010-06-29 10:55 That's not a bug. Maybe a missing feature if you really want to push it. There are no real bcd fields in Free Pascal, only currency-fields, which have a maximum of 4 decimals. ---------------------------------------------------------------------- Lacak2 · 2010-06-29 22:23 In Delphi6 is: Code: [Select]class procedure TBCDField.CheckTypeSize(Value: Integer); begin --- please don't publish copyrighted code, unless license allows this --- end; So it is more tolerant ... may be that, this is also way for FPC ... at least it will not lead to exception -or- Add support for TFMTBcdField ... we have TBcd type (fmtbcd.pp) ... so IMHO it is not very difficult (as template we can use TBcdField and modify methods to wrok with TBcd instead of system.currency) ---------------------------------------------------------------------- Lacak2 · 2010-06-30 19:11 Sorry So can I say, that in Delphi can Value be less than 33 ? (so not only 1..4, but 1..32) ---------------------------------------------------------------------- bonmario · 2010-06-30 19:34 I'ts already in Mantis: http://bugs.freepascal.org/view.php?id=13652 assigned last year, but without changes ...