Recent

Author Topic: ODBC TSqlQuery MySql float problem  (Read 12647 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
ODBC TSqlQuery MySql float problem
« on: January 13, 2010, 01:56:18 pm »
Hello, I'm creating a software that interfaces Lazarus with MySQL using ODBC, and so far so good, insert, remove, modify and read!

The problem occurred last night, which I incorrectly entered a number into a float in mysql, but when I run the query in a grid does not make me see the decimal part of number, why?!

If I try to read the data with FieldByName (). Asfloat

I still returns an integer.

If I put 8.7 gives me 8 if I put my 6.5 returns 6.

I tried both on Ubuntu than on Winzoz, strange case on winzoz works in Ubuntu and no!

Why is this happening?!

Sincerely

ps: please correct your answer, for me it's urgent! Thanks
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: ODBC TSqlQuery MySql float problem
« Reply #1 on: January 14, 2010, 09:03:30 am »
Please provide:
1. SQL structure of table on MySQL
2. version of MySQL
3. Check field type of "problematic field" (double click on TSQLQuery component, right-click "Add fields" ...)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #2 on: January 14, 2010, 12:47:25 pm »

1. SQL structure of table on MySQL

mysql> describe T_Tariffe;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| IdTariffa   | int(11)     | NO   | PRI | NULL    | auto_increment |
| NomeTariffa | varchar(50) | NO   |     | NULL    |                |
| Prezzo      | float(8,2)  | NO   |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
3 rows in set (0,02 sec)

2. version of MySQL: MySQL 5.1.37-1ubuntu5
3. Check field type of "problematic field" (double click on TSQLQuery component, right-click "Add fields" ...): return access violation error
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: ODBC TSqlQuery MySql float problem
« Reply #3 on: January 14, 2010, 01:58:33 pm »
My guess would be that it is a locale problem.

IOW is maybe "." not the decimal separator of your locale? :'(

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #4 on: January 14, 2010, 02:03:22 pm »
I do not know where to look what is the decimal point, but I know that MySQL uses the point as decimal separator. it inserted but it does read returns this problem!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: ODBC TSqlQuery MySql float problem
« Reply #5 on: January 15, 2010, 07:44:29 am »
Can you insert record into table using some MySQL utility, so we are sure, that number with decimal part is inserted ?
Then if you open this table, in TDBGrid still you see only integer part of number ?
Is this only Ubuntu problem, on Windows it works as expected ?
« Last Edit: January 15, 2010, 07:46:13 am by LacaK »

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #6 on: January 15, 2010, 08:00:28 am »
Have entered into MySql and the decimal part is present, but when the call given by Lazarus I can not see it. On window is perfect, no problem, the problem persists only on Ubuntu 64-bit, Italian language! But in my opinion is not a problem of TDBGrid as the TSqlQuery, because if I go to read the field code with FieldByName (). AsFloat me only returns the integer part of number. I tried to set also DecimalSeparator=',' and the ThousandSeparator='.' but the problem persists! Help me please  :'( :'( :'( :'(
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: ODBC TSqlQuery MySql float problem
« Reply #7 on: January 15, 2010, 12:20:31 pm »
Hm, may be, that the problem is related:
1. to 64bit environment
or/and
2. Ubuntu

In this case I can not help you, because I am working only with 32bit Windows.
If somebody else confirms , that problem really exists, may be it is bug in FPC ... then you should post bug report.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #8 on: January 15, 2010, 01:47:13 pm »
Who takes care of putting the bug in the bug report?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: ODBC TSqlQuery MySql float problem
« Reply #9 on: January 15, 2010, 02:43:11 pm »
You must post bug-report (if you are sure, that it is bug in Free Pascal). You can do it here http://bugs.freepascal.org/my_view_page.php
(but fixing may take months, so do not expect fast solution)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #10 on: January 15, 2010, 03:00:49 pm »
Ma non sono sicuro al 100% che sia un problema di lazarus. Però tutto fa pensare ciò!

Non ho mai postato un bug, mi spieghi come fare, quale voce devo cliccare?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: ODBC TSqlQuery MySql float problem
« Reply #11 on: January 18, 2010, 09:08:49 am »
Then I replaced the object TODBC with TMySQL50Connection and everything now works, then I think that the problem is the object TODBC in Ubuntu Desktop 64 bit!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018