dbExpress does not read the milliseconds part of TimeStamp fields

天涯浪子 提交于 2019-12-23 02:57:09

问题


Recently some Delphi / InterBase applications display

"Record not found or changed by another user"

They use the default TSQLQuery/TClientDataSet (or TSimpleDataSet) components of dbExpress.

We found that in the database table, a field was stored with milliseconds by a non-dbExpress application.

It looks like dbExpress did not read the milliseconds from DB, and use that truncated value in the 'where' condition of the update table SQL statement, so there was no matching record to be updated.

Update: we are using TSQLTimeStamp fields in the Delphi application. No OnBeforePost handlers are modifying the field value.

Update 2

As can be seen in IBExternals.pas PCTimeStructure does not have a milliseconds part. So 'by design' no support of milliseconds for InterBase in Delphi (2009).

Does anybody know if ms support has been added in a later version of Delphi?


回答1:


I guess it's the isc_decode_timestamp Interbase/Firebird client API which doesn't support milliseconds. Here is a related Firebird tracker issue.

Update: also see this answer.




回答2:


Don't know dbexpress well enough to say one way or another, but it may wel be the database that is doing the trimming. I do know that for example SQL server does drop milliseconds that are passed to it. You could try TIMESTAMP columns instead of DATETIME (not sure about exact names). Perhaps TIMESTAMP columns do have a millisecond resolution in the database you are using.




回答3:


var
  tmpDTS: string;
  tmpDT: TDateTiume;

DateTimeToString(tmpDTS,'yyyy"."mm"."dd" "hh"."nn"."ss" "zzz',tmpDT);

With this format I insert a record in a Firebird table (via TSQLQuery) and Flamerobin shows the exact value.

Instead, if I insert the value by means of a TDateTime parameter, milliseconds are truncated. DBGrid shows values truncated.

Delphi XE, Db Express, driver Firebird, Firebird 2.5.1 .



来源:https://stackoverflow.com/questions/5271799/dbexpress-does-not-read-the-milliseconds-part-of-timestamp-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!