ODAC -

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
andrefm
Posts: 37
Joined: Wed 23 Oct 2013 10:02

ODAC -

Post by andrefm » Tue 31 Mar 2015 09:28

Table in Oracle 11g R2 with a field called STARTTIME type TIMESTAMP(6).
I'm preparing an insert statement like:

Code: Select all

  ...
  QR_TABLE_INSERT.ParamByName('STARTTIME').DataType := ftOraTimeStamp;
  QR_TABLE_INSERT.Prepare; 
I have a variable dtStartTime from type TDateTime which contain a date and time with milliseconds.
When I execute:

Code: Select all

  QR_TABLE_INSERT.ParamByName('STARTTIME').AsDateTime := dtStartTime;
  QR_TABLE_INSERT.Execute;
The SQL statement is something like:

Code: Select all

INSERT INTO MY_TABLE
  (ID, FIELD1, STARTTIME)
VALUES
  (:ID, :FIELD1, :STARTTIME)
After I insert, the field STARTTIME contain the date and time, but no milliseconds (000).
Could you please let me know is this is a bug or how can I avoid loosing the milliseconds?

I guess the ".AsDateTime" might be the problem because if I just use the .Value and copy from another table, then I don't loose the milliseconds.
Example:

Code: Select all

QR_TABLE_INSERT.ParamByName('STARTTIME').Value  := QR_OTHER_TABLE.ParamByName('DATE_TIME').Value;
Using ODAC 9.4.14 with XE7 Enterprise.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ODAC -

Post by AlexP » Tue 31 Mar 2015 11:27

Hello,

If you are using the AsDateTime property, then, independently on the set parameter type, it will be changed to ftDateTime in the TParam.SetAsDateTime standard method. To work with TimeStamp parameters, you can use the AsSQLTimeStamp property and map your data to this type:

Code: Select all

dt := now;
OraQuery1.ParamByName('p2').AsSQLTimeStamp := DateTimeToSQLTimeStamp(dt);

andrefm
Posts: 37
Joined: Wed 23 Oct 2013 10:02

Re: ODAC -

Post by andrefm » Tue 31 Mar 2015 11:30

Thank you very much for the very quick response. It worked well.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ODAC -

Post by AlexP » Tue 31 Mar 2015 12:40

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply