Timestamp info sometimes incorrect in Direct mode
Posted: Mon 21 Mar 2022 18:24
Hello,
When I run this SQL in a TSmartQuery using an Oracle client, I get the expected result.
When I run it in Direct Mode, I am getting inconsistent results, I think depending on the value of DBTIMEZONE.
Edit: I have altered a database using: alter database set time_zone = '-07:00', then restarted it. I was not able to reproduce the problem in this way. Maybe it is caused by something else. If there is anything else that I can provide, please let me know.
Please see details in the image below.
https://imgur.com/a/WOx9hsy
I am using Delphi 10.2.3, compiled in 32 bit.
ODAC version 12.0.2
My source code is below:
Unit1.dfm:
Unit1.pas:
Project1.dpr:
When I run this SQL in a TSmartQuery using an Oracle client, I get the expected result.
Code: Select all
select systimestamp, sysdate,
sessiontimezone, localtimestamp(6),
dbtimezone, current_timestamp(6),
current_date
From dual
Edit: I have altered a database using: alter database set time_zone = '-07:00', then restarted it. I was not able to reproduce the problem in this way. Maybe it is caused by something else. If there is anything else that I can provide, please let me know.
Please see details in the image below.
https://imgur.com/a/WOx9hsy
I am using Delphi 10.2.3, compiled in 32 bit.
ODAC version 12.0.2
My source code is below:
Unit1.dfm:
Code: Select all
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 122
ClientWidth = 1026
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 1026
Height = 122
Align = alClient
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object OraSession1: TOraSession
Username = 'jdorlon'
Left = 24
Top = 16
EncryptedPassword = '95FF9BFF90FF8DFF93FF90FF91FF'
end
object SmartQuery1: TSmartQuery
Session = OraSession1
SQL.Strings = (
'select systimestamp, sysdate, '
' sessiontimezone, localtimestamp(6),'
' dbtimezone, current_timestamp(6),'
' current_date'
'From dual ')
Left = 96
Top = 16
end
object DataSource1: TDataSource
DataSet = SmartQuery1
Left = 160
Top = 16
end
end
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.Grids, Vcl.DBGrids, MemDS,
DBAccess, Ora, OraSmart, OraCall;
type
TForm1 = class(TForm)
OraSession1: TOraSession;
SmartQuery1: TSmartQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
OraSession1.Options.Direct := true;
OraSession1.LoginPrompt := False;
OraSession1.Server := '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ...)(PORT = 1521))(CONNECT_DATA = (INSTANCE_NAME = ...)(SERVER = DEDICATED)(SERVICE_NAME = ...)))';
OraSession1.Connected := True;
SmartQuery1.Execute;
end;
end.
Code: Select all
program Project1;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.