CDSClone:= TClientDataSet.create(self);
CDSCLone.CloneCursor(tableb,False);
cdsclone.first;
while not cdsclone.eof do
begin
cdsclone.datasetfield.nesteddataset.first
while not cdsclone.datasetfield.nesteddataset.eof do
begin
extractedvalue:=
cdsclone.DataSetField.NestedDataSet.Fields[2].value
if extractedvalue = savedvalue showmessage('duplicate value')
cdsclone.datasetfield.nesteddataset.next
end
cdsclone.next
end;
Thanks in Advance!
Debbie Erickson
Do you just want to test for any duplicate? If so, maybe you could consider
using an index to do a lot of the work for you. By declaring an Index with
the Unique option, would it not raise an exception and achieve what you
want?
However, if you want to weed out the duplicates, then you are faced with
walking the Dataset as per your example. even so, setting an index so the
dataset is ordered will help you.
I dont understand why you are working down into the nested dataset from
Table B. Would it not be a lot more readable of you hooked your dataset to
Table C, and just walked down it the way you are doing now?
Tony
"Debbie Erickson" <kn...@montereypark.ca.gov> wrote in message
news:3deff6ed$1...@newsgroups.borland.com...
Table A contains a list of departments. Table B contains the purchase
orders of each department. Table C contains the detail line items of each
purchase order within Table B. Each of these tables are already connected
to each other in a master/detail/detail relationship where Table B is a
detail to Table A and Table C is a detail to Table B. I use ado dataset in
combination with clientdataset and do all my updates in a single
transaction.
This application is a dataentry screen for the departments. When I open a
department, the detail is shown on grids within tabs on the screen. So the
department is the first tab, the grid listing purchase orders on the second
tab, and the grid listing the detail lines is on the third tab. You go to
the purchase order tab, navigate thru the records, and the detail line data
on the third tab reflects only the records associated with that particular
purchase order. In the tool bar I have a save button. One of the
constraints I have is that a "widget" cannot be ordered by two different
purchase orders within the same department. I don't think I can setup an
index on Table C because the widget could be ordered by a different
department. Therefore it is not totally unique.
When I get ready to post the department, I need to search thru ALL the
nested purchase order detail lines that are connected indirectly to the
department to determine duplicates. If there are duplicates present, I
abort the transaction update. And I need to do this without disturbing any
current cursor in the clientdataset. So I clone it. I was reading the docs
about nested client dataset and it sounded like it was suited to what I
wanted to do. I could clone both Table B and Table C. But from the docs
that come with Delphi it sounded like it was preferable to access it thru
the tdatasetfield component. But there are no examples on it's usage. The
complier doesn't complain about my code, but it fails with a runtime error.
In short, Help, please!
"Tony Blomfield" <to...@sailaway.co.nz> wrote in message
news:3df0...@newsgroups.borland.com...
with tdatasetfield(dataset.fieldbyname('somefield')).nextdataset do
begin
first
while not eof do
begin
{do your process upon this record here}
next
end
end;
Thanks for your time!
Debbie
I can't find nextDataset as a valid method of a Tdatasetfield?
--
Brian Bushay (TeamB)
Bbu...@NMPLS.com
The line SHOULD have read:
with tdatasetfield(dataset.fieldbyname('somefield')).NestedDataset do ....
"Brian Bushay TeamB" <BBu...@Nmpls.com> wrote in message
news:3jl2vukobcu0if373...@4ax.com...