Page 1 of 1

TUniLoader and DateTime with milliseconds (MySQL]

Posted: Tue 20 May 2014 16:03
by martin.trummer
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?

Re: TUniLoader and DateTime with milliseconds (MySQL]

Posted: Wed 21 May 2014 07:50
by martin.trummer
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).

Re: TUniLoader and DateTime with milliseconds (MySQL]

Posted: Fri 23 May 2014 11:35
by PavloP
>> 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.