Bug 62689 - Getting wrong double's from MySQL with libreoffice-basic
Summary: Getting wrong double's from MySQL with libreoffice-basic
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.5.7.1 rc
Hardware: x86 (IA32) Linux (All)
: high critical
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-24 12:06 UTC by sbatto
Modified: 2014-01-03 21:02 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
.odb with macro incorporating sbatto's code plus some corrections and additions (4.06 KB, application/vnd.oasis.opendocument.database)
2014-01-03 21:00 UTC, Terrence Enger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sbatto 2013-03-24 12:06:06 UTC
Since version 3.5.7 of libreoffice I get wrong double values in libreoffice-calc from the mySql database with libroffice-basic. It worked fine until 3.5.4.

The query using mysql - commandline:

[code]
mysql> select eurprice  from items where itemcode ="wbv";
+----------+
| eurprice |
+----------+
|   8.6000 |
+----------+
1 row in set (0.00 sec)
[/code]


The same from libreoffice-calc with libreoffice-basic, _same database_ of course:


[code]
Dim price as double
Dim selectString as string
Dim Statement As Object
Dim ResultSet As Object

selectString = "select eurprice from items where itemcode = '"wbv'"
Statement = gConnection.createStatement()
ResultSet = Statement.executeQuery(selectString)

.... ' some error handling here

price = ResultSet.getDouble(1)
[/code]

For 'price' I get just '8' instead of '8.6'

The code above had proven to work for some years now, but since my update to 3.5.7 (Ubuntu:1.3.5.7 to be precise) my reults are wrong. With 3.5.4 everything was still fine.

After downgrade from 3.5.7 to to 3.5.4 everything is fine again.
Comment 1 sbatto 2013-03-24 12:10:02 UTC
I can not tell wether the version was 3.5.7.1. or 3.5.7.2, but it was one of these.

I consier this bug critical as it simply yyields wrong results thus making e.g. any billing-software unusable. The bug silently produces wrong numbers. I detected id by accident.
Comment 2 Terrence Enger 2013-12-30 13:42:47 UTC
sbatto,

It would help us if you give us some more information:

(1) Does you problem still happen with a recent version of
    LibreOffice?  You can get one from
    <http://www.libreoffice.org/download/>.

(2) What database engine are you connecting to?  By what method?

(3) Please give us the definition of table "items".  Some sammple data
    would not hurt.

(4) Please attach a .odb file with the macro.  Remember that
    attachments are available to the whole world, so you may not want
    to create a new .odb which omits anything confidential.

Thank you for helping us improve LibreOffice.
Terry.
Comment 3 sbatto 2013-12-30 17:32:12 UTC
As I've left ubuntu and have a debian installation now, all versions have changed thus making it impossible to reproduce the exact situation. I could easily reproduce the error withe the above mentioned configuration and version, but now things have changed. I do not use a recent version and cannot install one under debian wheezy.

However, here's what I still can do for you:

1. Table description:

mysql> describe items;
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| itemcode     | varchar(10)  | NO   | PRI | NULL    |       |
| description  | varchar(256) | NO   |     | NULL    |       |
| eurprice     | decimal(9,4) | NO   |     | NULL    |       |
| unit         | varchar(10)  | NO   |     | NULL    |       |
| taxcode      | int(11)      | NO   |     | 1       |       |
| invoiceGroup | varchar(40)  | NO   |     | NULL    |       |
| maxunits     | decimal(9,4) | NO   |     | 0.0000  |       |
+--------------+--------------+------+-----+---------+-------+

mysql> select * from items;
+----------+------------------+----------+-------+---------+------------------+----------+
| itemcode | description      | eurprice | unit  | taxcode | invoiceGroup     | maxunits |
+----------+------------------+----------+-------+---------+------------------+----------+
| flt      | flight ticket    |   0.0000 | doc   |       1 | travelling costs |   0.0000 |
| who      | Webhosting       |   8.6000 | mon   |       1 |                  |   0.0000 |
| oed      | other efforts    |   0.0000 | doc   |       1 | other efforts    |   0.0000 |
| wbv      | webconsult       |   8.6000 | mon   |       1 |                  |   0.0000 |
+----------+------------------+----------+-------+---------+------------------+----------+
4 rows in set (0.00 sec)


2. Database is mysql as already described in my first post. 
3. I am using openoffice basic to access the database (as already described in my first post. ...)
4. This is how I connect:

gDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
	gDataSource = gDatabaseContext.getByName("mydatabase")

	If Not gDataSource.IsPasswordRequired Then
	   gConnection = gDataSource.GetConnection("","")
	Else
	   gInteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
       ' msgbox gInteractionHandler.dbg_properties     ' 
	   gConnection = gDataSource.ConnectWithCompletion(gInteractionHandler)
	End If

The connection is configured in a 'mydatabase.odb' file. I think it's an odbc connection.

5. The oo-basic statements I used are, guess what, - already described in my first post.
5. Operating system is linux.
6. Frontend is oo-calc (libreoffice)

Ok, my request is now 9 months old. I tried to live with that for some weeks, but than I downgraded as described above in my first post. Now, under debian,   I am using LibreOffice 3.5.4.2, Build-ID: 350m1(Build:2), were everything is fine.

Somehwat late to remember all the details.

Hope I could help.
Comment 4 Terrence Enger 2014-01-03 21:00:33 UTC
Created attachment 91471 [details]
.odb with macro incorporating sbatto's code plus some corrections and additions

The included macro `sbatto_01` shows price = 8.6.

Comments identify code that I have added or changed.
Comment 5 Terrence Enger 2014-01-03 21:02:42 UTC
I cannot point to just what has changed since sbatto reported this
problem.  So, am setting status WORKSFORME.