Apache OpenOffice (AOO) Bugzilla – Issue 115436
mysql Cast(col1 as CHAR) yields error
Last modified: 2010-12-18 08:47:58 UTC
Reproduce: 1. Connect Base to mysql database (assuming there is a table created) 2. Query with SQL: "Select CAST(Col1 as CHAR) as Col1 From Table1" error occurs As far as my observations yielded, it's a connector independent bug.
I can confirm it, the fiedd data type is VARCHAR. I tested on win7 with MySQL 5.1.44 with native (1.0.1), JDBC and ODBC driver. Same results, error: The data content could not be loaded. SQL Status: 42000 Error code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAR ) AS "field_name" FROM "table1"' at line 1 If I use query on DATE data type field, Select CAST(Col1 as DATE) as Col1 From Table1 I get error: The data content could not be loaded. SQL Status: 42000 Error code: 1584 Incorrect parameters in the call to stored function 'CAST' Both query runs in MySQL Workbench without error. I tested in OOo 3.2.1, I get same results with ODBC and JDBC drivers. Surprisingly the native driver 1.0.0 let the queries run, both works correctly. Other CAST Queries run without error: SELECT CAST('2000-01-01' AS DATE); SELECT CAST(1-2 AS UNSIGNED) select cast('2007-12-25' as DATETIME) Assign developer.
sinds OOO330m17 cast(timestamp as date ) works no longer also
I tested a 5.04 with OOo 3.2, 3.2.1, 3.3, DEV300m94 and I got the same error when connecting through - ODBC - JDBC - native connector And I tested the ODBC driver with the odbcte32.exe from MS with the same error. So OOo is out of the line. The convert(dd,DATE) function does the job for me. On the other side I also tested the mySQL workbench and the CAST function worked. I don't know what they use. This a bug in the connectors which I can' fix.
I found the reason.
The reason is that for MySQL the statement SELECT CAST('2001-01-01' AS DATE) as `MyDate` FROM `testdb`.`i115436`; works but SELECT CAST ('2001-01-01' AS DATE) as `MyDate` FROM `testdb`.`i115436`; doesn't. You see the space between the CAST and the bracket.
Fixed in cws dba33m
Please verify. Thanks.
patch reviewed
I have checked that the following SQL String works now SELECT CAST ('2010-12-09' AS DATE) FROM "test"."tt_test_create-table" with mysql and the mysql native connector
I tested cws dba33m on ubuntu 10.10 32bit linux, and queries: SELECT CAST(`datum` AS CHAR) as `MyDate` FROM `test`.`Tabla1`; SELECT CAST(`datum` AS DATE) as `MyDate` FROM `test`.`Tabla1`; SELECT CAST ('2010-12-09' AS DATE) FROM `test`.`Tabla1`; Runs without problem with JDBC and native connection.
I checked in OOo 3.3RC8 (m18), and no error occurs. Closing.