Page 1 of 1
Problem with fields named "field#"
Posted: Wed 19 Mar 2008 00:46
by MarkF
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
Posted: Wed 19 Mar 2008 09:20
by Plash
We can reproduce this problem in design-time editor only. Please specify, if you can reproduce it at runtime, and provide your Pascal code.
Posted: Wed 19 Mar 2008 12:32
by MarkF
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
Posted: Thu 20 Mar 2008 08:24
by Plash
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.
Posted: Thu 20 Mar 2008 12:09
by MarkF
Thanks! That solves my problem.
-Mark