Code: Select all
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 198
ClientWidth = 543
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 360
Top = 123
Width = 81
Height = 13
Caption = 'Records in query'
end
object Memo1: TMemo
Left = 8
Top = 8
Width = 320
Height = 169
Lines.Strings = (
'Memo1')
TabOrder = 0
end
object Button1: TButton
Left = 360
Top = 152
Width = 162
Height = 25
Caption = 'Open'
TabOrder = 1
OnClick = Button1Click
end
object SpinEdit1: TSpinEdit
Left = 447
Top = 120
Width = 75
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 2
Value = 24
end
object OraQuery1: TOraQuery
SQL.Strings = (
'SELECT sysdate a, sysdate b'
'FROM dual'
'CONNECT BY LEVEL <= :param')
AfterFetch = OraQuery1AfterFetch
Left = 144
Top = 72
ParamData = <
item
DataType = ftInteger
Name = 'param'
Value = nil
end>
object OraQuery1A: TDateTimeField
FieldName = 'A'
end
object OraQuery1B: TDateTimeField
FieldName = 'B'
end
end
object OraSession1: TOraSession
ConnectDialog = ConnectDialog1
Left = 144
Top = 16
end
object ConnectDialog1: TConnectDialog
Caption = 'Connect'
ConnectButton = 'Connect'
CancelButton = 'Cancel'
Server.Caption = 'Server'
Server.Visible = True
Server.Order = 1
UserName.Caption = 'User Name'
UserName.Visible = True
UserName.Order = 2
Password.Caption = 'Password'
Password.Visible = True
Password.Order = 3
Home.Caption = 'Home Name'
Home.Visible = False
Home.Order = 0
Direct.Caption = 'Direct'
Direct.Visible = False
Direct.Order = 6
Schema.Caption = 'Schema'
Schema.Visible = False
Schema.Order = 4
Role.Caption = 'Connect Mode'
Role.Visible = False
Role.Order = 5
Left = 248
Top = 64
end
end
Unit1.pas
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, DBAccess, OdacVcl, OraCall,
Vcl.Forms, Data.DB, Ora, MemDS, Vcl.Samples.Spin, Vcl.StdCtrls, Vcl.Controls;
type
TForm1 = class(TForm)
OraQuery1: TOraQuery;
Memo1: TMemo;
OraSession1: TOraSession;
Button1: TButton;
ConnectDialog1: TConnectDialog;
SpinEdit1: TSpinEdit;
OraQuery1A: TDateTimeField;
OraQuery1B: TDateTimeField;
Label1: TLabel;
procedure OraQuery1AfterFetch(DataSet: TCustomDADataSet);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure Log(const s: string);
procedure LogVariable(const name, value: string);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
OraQuery1.Close;
Memo1.Lines.Clear;
OraQuery1.FetchAll := True;
OraQuery1.NonBlocking := True;
OraQuery1.Params[0].Value := SpinEdit1.Value;
OraQuery1.Open;
end;
procedure TForm1.Log(const s: string);
begin
Memo1.Lines.Add(s);
end;
procedure TForm1.LogVariable(const name, value: string);
begin
Memo1.Lines.Add(name + ': ' + value);
end;
procedure TForm1.OraQuery1AfterFetch(DataSet: TCustomDADataSet);
begin
Log('##### AfterFetch #####');
LogVariable(' FetchRows', IntToStr(OraQuery1.FetchRows));
LogVariable(' Fetching', BoolToStr(DataSet.Fetching, True));
LogVariable(' Fetched', BoolToStr(DataSet.Fetched, True));
LogVariable(' OraQuery1A.Value', OraQuery1A.AsString);
case DataSet.Fetched of
False: Log('DATASET NOT READY');
True: Log('DATASET READY');
end;
if SpinEdit1.Value < OraQuery1.FetchRows then
begin
if OraQuery1A.AsString = '' then
Log('>> BUG <<')
else
Log('The problem is fixed!');
end;end;
end.
OraQuery1A.Value should not be empty for all param values below 25