BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TADODataSet and missing ROWID

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Clayton Arends
Guest





PostPosted: Thu Jun 29, 2006 11:00 pm    Post subject: TADODataSet and missing ROWID Reply with quote



Friends,

I ran across this problem today when I was porting a project. It access
Oracle directly and we are converting it to use ADO instead. Some tables
that it accesses have no unique record identifiers and instead use the ROWID
field for this purpose. When porting the following SQL I found that the
ROWID column was missing from the result set:

select ROWID, somefield from sometable

I performed a Google search and found plenty of people who had asked this
question but never found an answer to solve the problem (aside from answers
like "design your tables to have a unique record id"). So, I am writing
this post to show my solution and find out other people's opinions on this
subject.

I looked at ADODB.PAS and found that the VCL implementation was
intentionally hiding row id fields:

{ in TCustomADODataSet.InternalInitFieldDefs }

if ((adFldRowID and F.Attributes) <> 0) then
Attributes := Attributes + [faHiddenCol];

My solution is to descend a class from TADOQuery (since that's the component
I am really using) and override InternalInitFieldDefs:

TMyADOQuery = class(TADOQuery)
protected
procedure InternalInitFieldDefs; override;
end;

procedure TMyADOQuery.InternalInitFieldDefs;
var
i : integer;
begin
inherited;

for i := 0 to FieldDefs.Count - 1 do
begin
with FieldDefs.Items[index] do
Attributes := Attributes - [faHiddenCol];
end;
end;

Does anyone know the reasoning behind Borland's decision to hide row id
fields? Does this solution appear to be the best one given the
circumstances?

- Clayton

BTW - I am a BCB programmer and have translated my code to OP for this post.
Please forgive me if it's not entirely compilable. I posted here since the
Delphi groups have a greater user base than the equivalent BCB groups. I
used BCB6 for this solution and haven't tested it in BDS2006 yet.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.