TIMESTAMP(0) problem

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

TIMESTAMP(0) problem

Post by jdorlon » Fri 07 Dec 2012 15:48

Hello,

I have a table that was created like this:

Code: Select all

create table ts_zero
(ts_zero_col timestamp(0));

insert into ts_zero
select systimestamp
from dual;

commit;
Now, when I select from it with a TSmartQuery attached to a TDBGrid, the format is this:

12/7/2012 9:35:03. AM

Notice the extra dot after the seconds. There are no fractional seconds because it is TIMESTAMP(0), so the dot shouldn't be there either.

It presents a problem when I take that data and try to put it into a TO_TIMESTAMP() expression because the data format does not match what I see in TOraTimeStamp.Format.

I am using the latest ODAC version. If there is a change I can make to the ODAC source to fix it without having to wait for an update, please let me know.

Thanks,

John Dorlon

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Re: TIMESTAMP(0) problem

Post by jdorlon » Fri 07 Dec 2012 16:08

Ah! I believe I've found the solution.

In OraClasses, TOraTimeStamp.SetFormat...

Change this

Code: Select all

        's','S': begin
          Inc(P);
          if AnsiPos('Z', UpperCase(Str)) = 0 then begin
            Temp := {$IFDEF VER16P}FormatSettings.{$ENDIF}DecimalSeparator + 'FF'; // + IntToStr(Precision); does not work on Oracle 9.0.1
          end else
to this

Code: Select all

        's','S': begin
          Inc(P);
          if (AnsiPos('Z', UpperCase(Str)) = 0) and (Precision > 0) then begin
            Temp := {$IFDEF VER16P}FormatSettings.{$ENDIF}DecimalSeparator + 'FF'; // + IntToStr(Precision); does not work on Oracle 9.0.1
          end else
I added "and (Precision > 0)".

If you agree with this solution, please include it in the next version. Thank you.

-John

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

Re: TIMESTAMP(0) problem

Post by AlexP » Mon 10 Dec 2012 11:08

Hello,

Thank you for the information, we have reproduced the problem, and will include the changes to the next ODAC version.

Post Reply