TUniLoader and DateTime with milliseconds (MySQL]

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
martin.trummer
Posts: 19
Joined: Mon 12 May 2014 14:16

TUniLoader and DateTime with milliseconds (MySQL]

Post by martin.trummer » Tue 20 May 2014 16:03

I have a MySql primary key field of DateTime(6) - so it must also store microseconds.

how can I use this with TUniLoader?

what I tried now is to just add a column (without field-type) and then put a string like this: '2014-05-20 15:49:14.000000' (in OnPutData).

this fails with an exception like:
First chance exception at $76A7C41F. Exception class EMySqlException with message
'#42000You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'double) VALUES ('2014-05-20 15:49:14.000000', '0')' at line 1'.
when I use this statement in the MySql workbench directly, it works:

Code: Select all

INSERT INTO `scb`.`pk_test`
(`time`,
`double`)
VALUES ('2014-05-20 15:33:32.000001', '7')
  • what does the TUniLoader do when I don't specify a data-type for a column? will it assume some default or will it read the type from the data-base and convert the Variant to this type?
  • I also thought about using a delphi TDateTime when I put the value to the TUniLoader, but the TDateTime seems to support only milliseconds (not microseconds)
  • is there a way to see the whole SQL statement that the TUniLoader sends to the database?

martin.trummer
Posts: 19
Joined: Mon 12 May 2014 14:16

Re: TUniLoader and DateTime with milliseconds (MySQL]

Post by martin.trummer » Wed 21 May 2014 07:50

oh - I just found the problem

for testing, I have called a column "double" which is a keyword in MySql.

TUniLoader does not escape the fieldnames with ticks (`) per default.
but I did escape the fieldname in my test in the MySql workbench - thus it worked for me.

so to solve the issue, I could simple rename the field to some non-keyword name, or set teh QuoteNames property (in the SpecificOptions of the TUniLoader to true).

PavloP
Devart Team
Posts: 149
Joined: Fri 24 Jan 2014 12:33

Re: TUniLoader and DateTime with milliseconds (MySQL]

Post by PavloP » Fri 23 May 2014 11:35

>> what does the TUniLoader do when I don't specify a data-type for a column? will it assume some default or will it read the type from the data-base and convert the Variant to this type?

TUniLoader uses metadata obtained from the server to set the column type.

>> I also thought about using a delphi TDateTime when I put the value to the TUniLoader, but the TDateTime seems to support only milliseconds (not microseconds)

The TDateTime Delphi data type supports only milliseconds.

>> is there a way to see the whole SQL statement that the TUniLoader sends to the database?

UniDAC doesn't allow to view the SQL query generated by the TUniLoader component.

Post Reply