Hi,

When insert record to a Firebird database with SQLDB the millisecond part of a TIMESTAMP field is sometimes 0 sometimes 999. I use Windows XP 32bit, Firebird 2.5.2 Embedded, fixes_1_0 branch and FPC 2.6.2. Tried with a snapshot (Lazarus-1.1-40778-fpc-2.7.1-20130410-win32.exe) too but the result is same.

My test database contains only one table:

CREATE TABLE TABLE1 (DATETIME_FIELD TIMESTAMP);

The test case:

procedure SQLDB;
var
  DB:TIBConnection;
  TR:TSQLTransaction;
  qSC:TSQLQuery;
  FS:TFormatSettings;

begin
  FS.ShortDateFormat:='yyyy/mm/dd';
  FS.ShortTimeFormat:='hh:nn:ss';
  FS.DateSeparator:='/';
  FS.TimeSeparator:=':';

  DB:=TIBConnection.Create(nil);
  DB.CharSet:='UTF8';
  DB.DatabaseName:='MYDB';

  DB.UserName:='SYSDBA';
  DB.PassWord:='masterkey';

  TR:=TSQLTransaction.Create(nil);
  TR.DataBase:=DB;
  TR.Params.Add('read_committed');
  TR.Params.Add('no_rec_version');
  TR.Params.Add('wait');
  TR.Params.Add('write');

  qSC:=TSQLQuery.Create(nil);
  qSC.DataBase:=DB;
  qSC.Transaction:=TR;

qSC.SQL.Add('INSERT INTO TABLE1 (DATETIME_FIELD) VALUES (:IN_DATETIME_FIELD);');

  DB.Connected:=True;

  TR.StartTransaction;

  qSC.Prepare;

qSC.ParamByName('IN_DATETIME_FIELD').Value:=StrToDateTime('2010/11/12 13:14:15',FS); //In the database: 2010/11/12 13:14:14:999
  qSC.ExecSQL;
qSC.ParamByName('IN_DATETIME_FIELD').Value:=StrToDateTime('2007/11/03 06:06:47',FS); //In the database: 2007/11/03 06:06:47:0
  qSC.ExecSQL;
qSC.ParamByName('IN_DATETIME_FIELD').Value:=StrToDateTime('2002/03/04 05:06:07',FS); //In the database: 2002/03/04 05:06:06:999
  qSC.ExecSQL;
qSC.ParamByName('IN_DATETIME_FIELD').Value:=StrToDateTime('2007/11/03 05:44:28',FS); //In the database: 2007/11/03 05:44:28:0
  qSC.ExecSQL;

  TR.Commit;
  DB.Connected:=False;
  TR.Free;
  DB.Free;
end;

Gabor

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to