ODAC 9.6.21 Error “ORA-00928: missing SELECT keyword”
Posted: Thu 14 Jan 2016 14:45
ODAC 9.6.21
Create test table
Run Project1
Click Button1
Exception -> ORA-00928: missing SELECT keyword
test.sql
Project1.dpr
Unit12.dfm
Unit12.pas
Error in function OraClasses -> TOCIRecordSet.RequestFieldsInfo -> Locate
The same error in UNIDAC 6.2.9 in function OraClassesUni -> TOCIRecordSet.RequestFieldsInfo -> Locate
Create test table
Run Project1
Click Button1
Exception -> ORA-00928: missing SELECT keyword
test.sql
Code: Select all
create table SCOTT.TEST_TBL(
a VARCHAR2(20) not null,
b NUMBER(1)
);
create or replace synonym SCOTT.TEST for SCOTT.TEST_TBL;
Code: Select all
program Project1;
uses
Vcl.Forms,
Unit12 in 'Unit12.pas' {Form12};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm12, Form12);
Application.Run;
end.
Code: Select all
object Form12: TForm12
Left = 0
Top = 0
ClientHeight = 299
ClientWidth = 635
Color = clBtnFace
ParentFont = True
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 8
Top = 8
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object DBGrid1: TDBGrid
Left = 0
Top = 39
Width = 635
Height = 260
Align = alBottom
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object OraSession1: TOraSession
Options.KeepDesignConnected = False
Username = 'scott'
Server = 'TEST'
LoginPrompt = False
Left = 320
Top = 16
EncryptedPassword = '8BFF96FF98FF9AFF8DFF'
end
object OraSQLMonitor1: TOraSQLMonitor
Left = 320
Top = 88
end
object SmartQuery1: TSmartQuery
Session = OraSession1
SQL.Strings = (
'Select * from test')
Left = 240
Top = 24
object SmartQuery1A: TStringField
FieldName = 'A'
Required = True
end
object SmartQuery1B: TIntegerField
FieldName = 'B'
end
end
object DataSource1: TDataSource
DataSet = SmartQuery1
Left = 240
Top = 80
end
end
Code: Select all
unit Unit12;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, DBAccess, Ora, OraCall,
Data.DB, DASQLMonitor, OraSQLMonitor, MemDS, Vcl.Grids, Vcl.DBGrids, OraSmart;
type
TForm12 = class(TForm)
OraSession1: TOraSession;
Button1: TButton;
OraSQLMonitor1: TOraSQLMonitor;
SmartQuery1: TSmartQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
SmartQuery1A: TStringField;
SmartQuery1B: TIntegerField;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
implementation
{$R *.dfm}
procedure TForm12.Button1Click(Sender: TObject);
begin
SmartQuery1.Insert;
SmartQuery1A.AsString := DateTimeToStr(Now);
SmartQuery1.Post;
end;
procedure TForm12.FormCreate(Sender: TObject);
begin
OraSession1.Open;
SmartQuery1.Open;
end;
end.
Code: Select all
procedure TOCIRecordSet.RequestFieldsInfo(Tables: TSQLObjectsInfo; Columns: TCRColumnsInfo);
function AddDBLink(DBLink: string): string;
begin
if DBLink <> '' then
Result := '@' + DBLink;
end;
function Locate(Query: TOCIRecordSet; RecBuf: IntPtr; const FieldNames: array of string; const Values: array of string): boolean;
var
i: Integer;
v: variant;
Fields: TList;
begin
{==Vs====================================================================}
Result := False;
{==Vs====================================================================}
Fields := TList.Create;
try
for i := 0 to Length(FieldNames) - 1 do
Fields.Add(Query.FieldByName(FieldNames[i]));
Query.SetToBegin;
while True do begin
Query.GetNextRecord(RecBuf);
if Query.Eof then
break;
Result := True;
for i := 0 to Fields.Count - 1 do begin
Query.GetFieldAsVariant(Fields[i], RecBuf, v);
if not SameText(VarToStr(v), Values[i]) then begin
Result := False;
break;
end;
end;
if Result then
Exit;
end;
{==Vs====================================================================}
// Result := True;
{==Vs====================================================================}
finally
Fields.Free;
end;
end;