Problem with fields named "field#"

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Problem with fields named "field#"

Post by MarkF » Wed 19 Mar 2008 00:46

Hi Folks,

It appears that there is a problem with query fields named "FIELD#" (FIELD with a number after it.) Here's a simple script that shows the problem:

Code: Select all

create table fieldtest (
  field1 varchar2(20),
  field2 varchar2(20));

-- This one will work.
select
field1,
field2
from fieldtest;

-- This one will fail.
select
field2,
field1
from fieldtest;
The second query fails with the error: "A component named Field2 already exists"

Any help is greatly appreciated!

-Mark Ford

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 19 Mar 2008 09:20

We can reproduce this problem in design-time editor only. Please specify, if you can reproduce it at runtime, and provide your Pascal code.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Wed 19 Mar 2008 12:32

I get the error at run time. Here's my code:

Code: Select all

procedure TForm1.TestButtonClick(Sender: TObject);
var
  OSession: TOraSession;
  OQuery: TOraQuery;
begin
  OSession := TOraSession.Create(nil);
  OQuery := TOraQuery.Create(nil);
  try
    OSession.Username := 'SCOTT';
    OSession.Password := 'TIGER';
    OSession.Server := 'MYSERVER';
    OSession.Connect();

    OQuery.Session := OSession;
    OQuery.SQL.Text := 'select field2, field1 from fieldtest';
    OQuery.Open();  // Throws the exception

  finally
    OQuery.Free();
    OSession.Free();
  end;
end;
My ODAC version is 6.25.2.14 and I'm using Delphi 2007 for Win32.

Here's the interesting part of the stack trace at the exception point just in case it helps:

Code: Select all

:7c812a5b kernel32.RaiseException + 0x52
DB.DatabaseError('?'...)
DB.DatabaseErrorFmt(???,???,nil)
DB.TNamedItem.SetDisplayName('Field2')
DB.TDefCollection.SetItemName(???)
DB.TFieldDefs.SetItemName($B92388)
Classes.TCollection.InsertItem($B92388)
Classes.TCollectionItem.SetCollection(???)
Classes.TCollectionItem.Create(???)
DB.TFieldDef.Create($B6DB70,'FIELD1',ftString,20,False,2)
MemDS.TMemDataSet.CreateFieldDefs
MemDS.TMemDataSet.InternalOpen
DBAccess.TCustomDADataSet.InternalOpen
Ora.TOraDataSet.InternalOpen
DB.TDataSet.DoInternalOpen
DB.TDataSet.OpenCursor(???)
MemDS.TMemDataSet.OpenCursor(False)
DBAccess.TCustomDADataSet.OpenCursor(False)
Ora.TOraDataSet.OpenCursor(False)
DB.TDataSet.SetActive(???)
DBAccess.TCustomDADataSet.SetActive(True)
DB.TDataSet.Open
Thanks,

Mark

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 20 Mar 2008 08:24

This problem is caused by a bug in DB unit.
You should assign a value to Name property of TOraQuery to avoid to the problem.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Thu 20 Mar 2008 12:09

Thanks! That solves my problem.

-Mark

Post Reply