Re:ask about two clientdataset join query
Hello !
ClientDataSet does not supports directly joins. But,
you can emulate that, depending on your needs, using
one of approaches:
1) Use master-detail relationship between two client
datasets. You can achive near transparency, using
following code:
function GetFieldCount: Integer;
begin
Result := clientdateSet1.FieldCount + clientdateSet2.FieldCount;
end;
function GetField(AIndex: Integer): TField;
begin
if AIndex < clientdateSet1.FieldCount then
Result := clientdateSet1.Fields[AIndex]
else
Result := clientdateSet2.Fields[AIndex - clientdateSet1.FieldCount];
end;
More or less, the same may be achived using other
clientdataset filtrating / searching techniques: Ranges,
Filters / Locate.
2) You can add calculated / lookup fields to
ClientDataSet1. And they will return field values of
ClientDataSet2.
3) You can create ClientDataSet3. It will consists
from fields of ClientDataSet1 and 2. And fill it using
data from ClientDataSet1 and 2. To join they data
using any approach from (1).
Regards,
Dmitry
===========================================
Dmitry L. Arefiev, director of gs-soft.ru ltd.
Solutions for successful companies
Author of NCOCI8 - Freeware Delphi to Oracle8i direct access
ICQ: 50741007
EMail: daref...@gs-soft.ru
Company: http://www.gs-soft.ru
NCOCI8: http://www.da-soft.com
Quote
"luorl" <lu...@telekbird.com.cn> wrote in message news:3eb24dbd@newsgroups.borland.com...
> hi
> I write a "briefcase model" application. I create two clientdatesets,
> the clientdateSet1's fields like this : ID,field1,field2 ,field3...
> the clientdateSet2's fields like this : ID,fieldA,fieldB ,fieldC...
> I want to get the resultSet like the sql: select clientdateSet1.ID ,
> clientdateSet1.field1, clientdateSet2.fieldA,clientdateSet2.fieldB where
> clientdateSet1.ID=clientdateSet2.ID and clientdateSet1.field1='ABCD'
> Thanks for any tips!
> luorl