TOraTimeStampField asDateTime works different
Posted: Thu 18 Sep 2008 15:09
Hi,
I have a problem with TOraTimeStampField.asdatetime function in TOraTable component.
I work with ODAC Build 6.50.0.37 and Delphi 7.
Reading a 'TIMESTAMP WITH LOCAL TIME ZONE'-Field and update it with the same value will increased it by 2 hours (I am here at GMT +1 summer time).
Here is a full example with TESTTABLE.
You will see that after Edit/Post the value is changed.
I think this behavior is not ok and you can help me.
Thank you
Edmund Pfundsein
I have a problem with TOraTimeStampField.asdatetime function in TOraTable component.
I work with ODAC Build 6.50.0.37 and Delphi 7.
Reading a 'TIMESTAMP WITH LOCAL TIME ZONE'-Field and update it with the same value will increased it by 2 hours (I am here at GMT +1 summer time).
Here is a full example with TESTTABLE.
Code: Select all
procedure TForm1.ButTestSQLFilterClick(Sender: TObject);
var
tblTestTable: TOraTable;
oraSession: TOraSession;
locCreate: TSTringlist;
locDrop: TStringlist;
locDateTime: TDateTime;
begin
locCreate := TStringlist.create;
locDrop := TStringlist.create;
oraSession := TOraSession.Create(self);
try
oraSession.HomeName := 'OraServerHome10201';
oraSession.ConnectString := 'scott/tiger@corpitDB';
oraSession.Connect;
// Create TestTable
locCreate.clear;
locCreate.Add('create table TESTTABLE (');
locCreate.Add(' ID NUMBER(10,0) ,');
locCreate.Add(' CDAT TIMESTAMP WITH LOCAL TIME ZONE)');
oraSession.ExecSQLEx(locCreate.Text, []);
// Insert one Row
oraSession.ExecSQLEx( 'insert into testtable values(1, to_date(''1.1.2008'', ''dd.mm.yyyy''))', []);
// Update Row with TOraTable
tblTestTable := TOraTable.create(nil);
try
tblTestTable.TableName := 'TestTable';
tblTestTable.Open;
try
tblTestTable.First;
locDateTime := tblTestTable.Fieldbyname('CDAT').asdatetime;
showmessage(Format('Before Update: Field: %s Value: %s', ['CDAT', tblTestTable.Fieldbyname('CDAT').asstring]));
tblTestTable.Edit;
try
tblTestTable.Fieldbyname('CDAT').asdatetime := locDateTime;
tblTestTable.post;
showmessage(Format('After Update: Field: %s Value: %s', ['CDAT', tblTestTable.Fieldbyname('CDAT').asstring]));
except
on e: exception do
begin
tblTesttable.cancel;
showmessage(e.message);
end;
end;
finally
tblTestTable.Close;
end;
orasession.Disconnect;
finally
if assigned(tblTesttable) then
FreeAndNil(tblTesttable);
end;
// Drop TestTable
locDrop.clear;
locDrop.add('Drop table TESTTABLE');
oraSession.ExecSQLEx(locDrop.Text, []);
finally
if assigned(oraSession) then
FreeAndNil(oraSession);
if assigned(locCreate) then
FreeAndNil(locCreate);
if assigned(locdrop) then
FreeAndNil(locdrop);
end;
end;I think this behavior is not ok and you can help me.
Thank you
Edmund Pfundsein